Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / CodeWarrior / September 2005



Tip: Looking for answers? Try searching our database.

How to get the FSSpec from a vRefNum

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
EricH - 13 Sep 2005 12:30 GMT
Hello,

I'm looking for a high-level OS X function that returns the FSSpec of
an opened file (knowing its vRefNum)?
Does it exist ?

Thanks,
Eric.
Ben Artin - 13 Sep 2005 15:17 GMT
> 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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.