On Fri, 26 Sep 2003, Mike H. wrote:
> This is probably a very stupid question, but I can't seem to get this to
> work. I had a very strong background programming in Classic...
> I want to create a file in a certain directory, /Library/Preferences/Folder.
> It should go on the main volume.
> I got a copy of MoreFilesX, and tried the following:
> UInt8 thePath;
> memset(thePath, 0, sizeof(thePath));
> strcpy((char*)thePath, "/Library/Preferences/MyFolder/test.txt");
> myErr = FSPathMakeFSSpec(
> &isDirectory);If you look at the code in the code, you will they that it first makes an>
> If ( myErr == fnfErr ) //file doesn't exist
> myErr = FSpCreate(&prefSpec,kMyCreatorCode,kMyTextType,smS ystemScript);
> However, this clearly doesn't work, giving me a volume not found error
> (-35). I tried specifying the volume directly, by noting kOnSystemDisk for
> the vRefNum in prefSpec, but no luck.
fsref for the path, then gets the fsspec. Since you can't have an FSRef
for a function that doesn't exist, you won't get a valid FSSpecYou should use the dirID and the volume number given to you by findfolder>
> So I tried again. This time I figured that if I specify the volume type
> (which I can get from FindFolder) then it should work. I put the following
> code in front of the FSpCreate call:
> myErr = FindFolder(kOnSystemDisk, kPreferencesFolderType, kDontCreateFolder,
> &myVRef, &myDirIDs);
> if (myErr == noErr)
> prefSpec.vRefNum = myVRef;
> Now I get an error -37.
to make your FSSpec.
If you want to use unicode filenames you should ditch the fsspecs and use
> I realize that there are all sorts of different domains---and that I'm
> probably a major idiot. Any ideas?
> Mike Hunson