On Feb 12, 2006, at 9:27 PM, Joseph J. Strout wrote:
At 3:05 PM -0700 2/12/06, Tim Jones wrote:
I always get the "UnsupportedFormatException" error when I get to the
path
element that doesn't exist.
If I recall correctly, the OS X routines that are based on paths can't
represent files that don't exist. To do what you want, you would need
to strip off the last part of the path, GetFolderItem on that, then
call .Child to get a reference to the nonexistent file.
Note that this code:
f1 = GetFolderItem(tmpPath, FolderItem.PathTypeShell) // (1)
if f1 = Nil Then
Debug.Print "f1 is Nil, creating folder"
f1 = New FolderItem(tmpPath, FolderItem.PathTypeShell) // (2)
is a bit nonsensical, since GetFolderItem and New FolderItem do
exactly the same thing, except that the latter raises an exception to
indicate failure while the former returns Nil. So if you failed at
point (1), it will always be fruitless to try again in form (2).
Ah, I didn't realize that they resulted in the same thing.
The path I get from the user (folders, not filenames):
/Volumes/My Drive/Personal/Backups
My pcode loop:
for i - 1 to CountFields(tmpPath, "/")
tmpPath = tmpPath + "/" + NthField(tmpPath, "/", i)
f1 = GetFolderItem(tmpPath, FolderItem.PathTypeShell)
If f1 = Nil Then
// Create the missing path (a folder)
End If
Next
That should drop through for each existing path, but if the user has
specified a non-existent folder, we create it (we've asked and checked
permission before entering this code).
So, what I'm trying to do is to take the shellpath provided and parse
and create missing elements.
Tim
But as I look at your message again, I'm confused -- you say you
already have code that walks through the path, creating missing
directories as you go. So you shouldn't need to be using
PathTypeShell, or any other path type for that matter -- you can just
start at the top, and give .Child one file name at a time, can't you?
This is what seems to be eluding me...
Tim
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>