> I'm looking for a high-level OS X function that returns the FSSpec of
> an opened file (knowing its vRefNum)?
> Does it exist ?
vRefNum is a volume reference number, so your question, as stated, makes no
sense at all. Assuming that you mean that you have the fork refnum, the API you
want is FSGetForkCBInfo (if the file was opened with FSOpenFork),
PBGetFCBInfoSync (if the file was opened with FSpOpenDF, FSpOpenRF, or
FSOpenResFile).
hth
Ben

Signature
If this message helped you, consider buying an item
from my wish list: <http://artins.org/ben/wishlist>
I changed my name: <http://periodic-kingdom.org/People/NameChange.php>
EricH - 19 Sep 2005 08:42 GMT
Hi Ben,
Thank you for your anwer.
You're right, I just have the refnum (int32 dataFork) of the opened
file.
Since I don't know how it was opened, I tried:
FCBPBRec fcb;
memset(&fcb, 0, sizeof(fcb));
Str31 fileName;
fcb.ioNamePtr = fileName;
fcb.ioRefNum = gStuff->dataFork;
throw PBGetFCBInfoSync(&fcb);
Result: non Ascii char in fileName
Then I tried:
HFSUniStr255 outForkName;
FSRef fsRef;
throw FSGetForkCBInfo(gStuff->dataFork, 0, NULL, NULL, NULL, &fsRef,
&outForkName);
FSSpec fSpec;
// to get FSSpec from FSRef:
throw FSGetCatalogInfo(&fsRef, 0, NULL, NULL, &fSpec, NULL);
Exception in FSGetCatalogInfo
Can you see a mistake in what I wrote ?
Eric.
Ben Artin - 22 Sep 2005 15:47 GMT
> Hi Ben,
>
[quoted text clipped - 9 lines]
> fcb.ioRefNum = gStuff->dataFork;
> throw PBGetFCBInfoSync(&fcb);
According to
<http://developer.apple.com/documentation/Carbon/Reference/File_Manager/file_mana
ger/chapter_1.2_section_36.html> you should also set fcb.ioFCBIndx = 0.
> HFSUniStr255 outForkName;
> FSRef fsRef;
[quoted text clipped - 7 lines]
>
> Can you see a mistake in what I wrote ?
Nothing besides what I mentioned above. It would be more helpful if I knew which
Mac OS error numbers you were getting from those calls, though.
Ben

Signature
If this message helped you, consider buying an item
from my wish list: <http://artins.org/ben/wishlist>
I changed my name: <http://periodic-kingdom.org/People/NameChange.php>
EricH - 19 Sep 2005 09:42 GMT
Hi Ben,
Apparently both methods work now.
Thanks,
Eric.