[futurebasic] Re: [FB] FSRef File Open For Writing

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : November 2008 : Group Archive : Group : All Groups

From: Brian Stevens <bstevens33@...>
Date: Sun, 30 Nov 2008 15:38:30 -0700
On Nov 30, 2008, at 3:02 PM, Deep wrote:
>
> How can an FSRef of a file be converted into the FSRef of the parent?

Deep, there is no conversion per se. A file has an FSRef and its  
parent folder ( directory ) also has an FSRef that is separate and  
different from the parent folder FSRef.

The easiest method to obtain the parent folder FSRef is to use the  
File Directory utility ( included with FBtoC as a header ). The FD  
ReadMe has a little more explanation but there are special calls just  
to obtain parent directories as either refs, urls or specs. The posted  
code is amended below to show what could be done.


'--------
include "Util_FileDirectory.incl"

local fn GetFileHandler( reply as ^NavReplyRecord, userData as pointer )
'~'1
dim as Str255   name
dim as FSRef    ref, parentFolderRef

NavDialog_GetItemFSRef( #reply, 1, @ref )
GetNameAsPascalStringFromFSRef( @ref, @name )

// Need to convert "ref" into "parentFolderRef"

long if ( fn FD_ParentDirectoryGetFSRef( @ref, @parentFolderRef ) ==  
_noErr )
open "O", 1, s, @parentFolderRef
print #1,"some dummy text"
close #1
end if
end fn
'------------



Brian S