ADC Home > Reference Library > Technical Q&As > Legacy Documents > Mac OS 9 & Earlier >

Legacy Documentclose button

Important: This document is part of the Legacy section of the ADC Reference Library. This information should not be used for new development.

Current information on this Reference Library topic can be found here:

Impossibility of Extracting File System Information from the WindowPtr

Q I need to get the full pathname to a document in a callback where the only relevant piece of information I have is the WindowPtr for the window that will contain the document. I know the filename, but I do not know the directory ID or volume reference number. Is there any way to obtain the dirID and vRefNum from the WindowRecord?

A Unfortunately, there is no way to extract the file system information you need from a WindowRecord. The WindowRecord includes only structural human interface information which might include the file name (actually the document's title). Windows provide a means of presenting the data of documents for the user, but the WindowRecords have no knowledge of where to find the file system information. As you have implied, you must have the directory ID and volume reference number to extract a full pathname.

Knowing the vRefNum and the parent dirID, you would be able to use one of the FullPath routines in the DTS Sample Code MoreFiles.

If you knew the file reference number, you could call PBGetFCBInfo() to get the vRefNum and dirID, then use MoreFiles to get your full pathname. PBGetFCBInfo() gives information about open files (files in the file control block queue). You call PBGetFCBInfo() like this:

 pascal    OSErr    GetFileLocation(short refNum,
        short *vRefNum,
        long *dirID,
        StringPtr fileName)
 {
     FCBPBRec pb;
     OSErr error;

     pb.ioNamePtr = fileName;
     pb.ioVRefNum = 0;
     pb.ioRefNum = refNum;
     pb.ioFCBIndx = 0;
     error = PBGetFCBInfoSync(&pb);
     *vRefNum = pb.ioFCBVRefNum;
     *dirID = pb.ioFCBParID;
     return (error);
 }

See Also:

  • For more information on File Control Blocks, see Inside Macintosh: Files, pp. 2-81 through 2-83.
  • For more information on PBGetFCBInfo, see Inside Macintosh: Files, pp. 2-237 through 2-238.

Updated: 14-May-96


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.