On 2007-12-05, at 17:19, Gary (Lists) wrote:
"Skeeve" wrote:
I still don't know how to conveniently handle filenames of files that don't yet exist
That's a red herring. Or a black hole. Or a white elephant.
If a file doesn't exist, then it can't possibly have a name.
Hold on a sec Gary (Lists),
Skeeve does have a faire complainte.
In previous systems, the support underlying files was FSSpec/AliasHandle. And it was possible to instantiate those items with non-existent file paths. See FSMakeFSSpec() in Files.h for instance. FSSpec has a 'name' field. An FSSpec or old-style AliasHandle could refer to a non-existent file. This had of practical value because as an object, a file can still have useful properties even if it's 'name' field is missing or refers to a file which doesn't exist.
In OS X, URLs (known as CFURLRef or NSURL in the system frameworks), although they don't have a 'name' field specifically, have a 'last path component' (see CFURLCreateCopyAppendingPathComponent() in CFURL.h for instance). And it is possible to create valid URLs with non-existent files. But AppleScript doesn't have much support for URLs even though they are more or less the global standard. Only, as you mention, for strings.
So let's speculate about this 'fs object' for a bit. It will have all the property fields that one observes with:
tell application "System Events"
properties of (file 1 of (path to desktop) whose name extension is "scpt")
end tell
plus 'data' and 'metadata' properties.
So:
set fsobj to make new fs object with properties {parent:path to desktop folder, data:"some text", type identifier:"public.text"}, name:"some.txt"}
write fsobj
set data of fsobj to "other text"
write fsobj
The critical criteria here being that 'parent' should be valid for the write calls but not necessarily for using an fs object as a virtual file container in a script.
So, you are not experiencing a problem of AppleScript, but a problem of your conceptualization of what is a file,
I think rather it's a problem with the AppleScript implementation of a useful 'fs object'.