Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jun 24, 2008, 05:23 AM   #1
pallavi0703
macrumors newbie
 
Join Date: Dec 2007
error for FSOpenFork

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.
pallavi0703 is offline   0 Reply With Quote
Old Jun 24, 2008, 08:13 AM   #2
gnasher729
macrumors G4
 
gnasher729's Avatar
 
Join Date: Nov 2005
Quote:
Originally Posted by pallavi0703 View Post
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.
Read the documentation for CFURLCreateFromFileSystemRepresentation. The comment for the second parameter says "The character bytes to convert into a CFURL object. This should be the path as you would use in POSIX function calls."
gnasher729 is offline   0 Reply With Quote
Old Jun 25, 2008, 03:03 AM   #3
pallavi0703
Thread Starter
macrumors newbie
 
Join Date: Dec 2007
now error for FSReadFork

Hello gnasher729,
Now I am using posix file path ,
but for reading file every time new error code is returned like -4628 ,-4132,-5380 etc.

ByteCount requestCount;
void *buffer;
ByteCount *actualCount;

result = FSOpenFork(&ref, dataForkName.length, dataForkName.unicode, fsRdPerm, &forkRefNum);// returns noErr
if(result == noErr) {

buffer = malloc(1024);
requestCount = 128;
Err1= FSReadFork(forkRefNum,fsFromStart,0, requestCount,&buffer, &actualCount);//program get hanged
}

Last edited by pallavi0703; Jun 25, 2008 at 04:24 AM.
pallavi0703 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
iPhone unknown error (-200) horace528 Mac Applications and Mac App Store 0 Oct 10, 2011 10:14 AM
Time Machine - Error 22 Randomly Appears VaatiKaiba OS X 1 Aug 29, 2011 01:45 PM
Resolved: iTunes error 3194 when restoring sclomps Jailbreaks and iOS Hacks 1 Mar 31, 2011 06:30 PM
For those of you who get quickpwn error for JB 2.1...ANSWER! rotobadger Jailbreaks and iOS Hacks 1 Oct 21, 2008 10:05 PM
I keep getting and error for ijailbreak? help please I-V-A-N-qws Jailbreaks and iOS Hacks 1 Feb 15, 2008 11:29 AM


All times are GMT -5. The time now is 01:19 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

Privacy / DMCA contact / Affiliate and FTC Disclosure
Copyright 2002-2013, MacRumors.com, LLC