file path from NavReplyRecord?

Post: #1
The use of FSSpecs and FSRefs is very confusing. I'd rather use fopen(char *name) to open and save text files. The NavReplyRecord structure contains information about requester results, but how do you get the full path of a file from it? There's a "saveFileName" field but I don't think that contains the file path. When working with requesters, what structure(s) need(s) to be examined to get the complete file path (volume and folder)? Also, how do you pass that information to a file-saving routine (that uses FSSpec or FSRef) without going through a requester?
Quote this message in a reply
Post: #2
Using a couple of snippets from iDev's archives I pieced together the following:

    CFBundleRef bundle;
    CFURLRef bundle_url=NULL;
    CFStringRef    sr=NULL;
    char path[1024];
       FSRef fsr;
       FSSpec fsp;
       Boolean *isdir=NULL;

    bundle = CFBundleGetMainBundle();
    if ( ! bundle )
        goto mac_fail;
    bundle_url=CFBundleCopyBundleURL( bundle );
    if ( ! bundle_url )
        goto mac_fail;
    sr=CFURLCopyFileSystemPath(bundle_url, kCFURLPOSIXPathStyle);
    if ( ! sr )
        goto mac_fail;
    if ( CFStringGetCString(sr, path, 1024, kCFStringEncodingASCII) )
             FSPathMakeRef((unsigned char *)path,&fsr, isdir); //Convert pathname to FSRef
              FSGetCatalogInfo (&fsr, kFSCatInfoNone,NULL, NULL,&fsp, NULL); //Convert it to FSSpec
           CFRelease( bundle_url );
           CFRelease( sr );

This works to open the Pict file, but "path" doesn't work with fopen().

The complete document path works out to something like "/users/me/desktop/app/new_title".

Missing is the volume name, I think. Any ideas on how to get this working with fopen()?
Quote this message in a reply
Posts: 151
Joined: 2002.09
Post: #3
are you sure your path is correct?
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Drawing a path in-game GregX999 3 4,468 Dec 1, 2010 07:16 AM
Last Post: GregX999
  Get path to user's "Application Support" folder Meh123 5 5,976 Nov 7, 2008 12:07 PM
Last Post: Wowbagger
  Path Finding bwalters 22 13,838 Mar 27, 2006 11:36 AM
Last Post: Blacktiger