file path from NavReplyRecord?
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?
Using a couple of snippets from iDev's archives I pieced together the following:
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()?
Code:
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) )
{
strcat(path,"/new_title");
FSPathMakeRef((unsigned char *)path,&fsr, isdir); //Convert pathname to FSRef
FSGetCatalogInfo (&fsr, kFSCatInfoNone,NULL, NULL,&fsp, NULL); //Convert it to FSSpec
doOpenFile(fsp,kFileTypePICT);
}
mac_fail:
if(bundle_url)
CFRelease( bundle_url );
if(sr)
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()?
are you sure your path is correct?
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Drawing a path in-game | GregX999 | 3 | 2,996 |
Dec 1, 2010 07:16 AM Last Post: GregX999 |
|
| Get path to user's "Application Support" folder | Meh123 | 5 | 4,748 |
Nov 7, 2008 12:07 PM Last Post: Wowbagger |
|
| Path Finding | bwalters | 22 | 9,308 |
Mar 27, 2006 11:36 AM Last Post: Blacktiger |
|

