[futurebasic] Re: [FB] 2 Questions about Converting to FSRefs

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : July 2010 : Group Archive : Group : All Groups

From: Bernie <fblist.bw@...>
Date: Sun, 4 Jul 2010 22:20:45 +0100
Walter wrote:

> I am in the process of learning about FSRefs by converting a program from FsSpecs to FsRefs. I am mostly doing OK, but there are 2 situations for which the conversion befuddles me - I would appreciate any words of wisdom. The 2 situations are:
> 
> 1. Getting a list of files in a folder. I am using Fn PBHGetFInfoSync( @pb ) with a pointer block. This requires filling in the block with the vRefNum% and the parID& for the folder. I am presently doing this by converting the FsRef to a FsSpec and extracting the information from the FsSpec. Is there a better way of doing this task?  My code example is below.

Take a look at Examples/Files/EnumerateDirectory.

> 2. Putting the contents of an .RTF file in a MLTE Edit field.  I have been using fn TXNNewObject( ) for this, which takes a fsSpec as one of it's arguments.  I am presently converting a FsRef to a FsSpec and passing that. Is there a better way?
> 
> BTW, TXNNewObject() is DEPRECATED in favor of TXNCreateObject() which only takes 3 arguments:
>  const HIRect *    iFrameRect,
>  TXNFrameOptions   iFrameOptions,
>  TXNObject *       oTXNObject)
> This implies that there could be a way of putting an .RTF file into an MLTE edit field (there has not been one before, AFAIK). Any ideas?

How about converting FSRef to CFURLRef then call TXNReadFromCFURL?

Bernie