Hello All,
In Xcode Carbon C bundel application I want to open a file and read data from it, but at runtime I am not able to make FSRef from file path. Following code I am using please tell me what changed are required in this code.
CFURLRef url ;
Boolean flag;
FSRef ref , ref2 ;
OSErr error ,result;
char *volname = NULL;
char revpath[PATH_MAX];
HFSUniStr255 dataForkName;
SInt16 forkRefNum;
volumeNameForPath("/", &volname);//user defined function to get default volume name
strcat(volname,":CFURL.txt");//now volname = "Macintosh HD:CFURL.txt" and strlen((char*)volname = 22
url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault,volname,strlen((char*)volname),false);
flag = CFURLGetFSRef((CFURLRef)url , &ref);//true if success else false
//flag returned is 0 it should be 1
or
error = FSPathMakeRef(volname,&ref2,false);
result = FSGetDataForkName(&dataForkName);
if (result != noErr) {
syslog(LOG_INFO, "FSGetDataForkName() returned %d", result);
return;
}
result = FSOpenFork(&ref, dataForkName.length, dataForkName.unicode, fsRdPerm, &forkRefNum);//result returned is -35.
Thanks & Regards,
Pallavi.
In Xcode Carbon C bundel application I want to open a file and read data from it, but at runtime I am not able to make FSRef from file path. Following code I am using please tell me what changed are required in this code.
CFURLRef url ;
Boolean flag;
FSRef ref , ref2 ;
OSErr error ,result;
char *volname = NULL;
char revpath[PATH_MAX];
HFSUniStr255 dataForkName;
SInt16 forkRefNum;
volumeNameForPath("/", &volname);//user defined function to get default volume name
strcat(volname,":CFURL.txt");//now volname = "Macintosh HD:CFURL.txt" and strlen((char*)volname = 22
url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault,volname,strlen((char*)volname),false);
flag = CFURLGetFSRef((CFURLRef)url , &ref);//true if success else false
//flag returned is 0 it should be 1
or
error = FSPathMakeRef(volname,&ref2,false);
result = FSGetDataForkName(&dataForkName);
if (result != noErr) {
syslog(LOG_INFO, "FSGetDataForkName() returned %d", result);
return;
}
result = FSOpenFork(&ref, dataForkName.length, dataForkName.unicode, fsRdPerm, &forkRefNum);//result returned is -35.
Thanks & Regards,
Pallavi.