Creation of a file using FSpCreate()??

darpan

Registered
Hi all

I have using the FSpCreate() for creating a file, when i compiling my application there is no error but still file is not created.I want to know about the FSSpec structure.

I have passed the following values to this structure
spec.vRefNum=0;
spec.parID=4029;
unsigned char filename[64]="Aman";
spec.name=filename;
FSpCreate(&spec, 'ttxt', 'TEXT', smSystemScript); *

I want to create file on root . What i should pass to parId and vRefNum?? How i can get the Volume reference number.

Thanks and Regards
 
You shouldn't modify the structure yourself. Use a function like FSMakeFSSpec to get a valid FSSpec.
 
kainjow said:
You shouldn't modify the structure yourself. Use a function like FSMakeFSSpec to get a valid FSSpec.


Hi

Now i am using the function FSMakeFSSpec to get a valid FSSpec but file is not created. I have making this program in QT Programming for Mac(C++ GUI programming kit by trolltech.org). I am trying to make a text file using programming.

I have used the following code:-

OSErr err;
FSSpec spec;
err=FSMakeFSSpec(0,0,"/unique/hello.txt",&spec);
if(err == fnfErr)
QMessageBox::information(0, "message","hiiiiiiiiii");

FSpCreate(&spec, 'CWIE', 'TEXT', smSystemScript);


I have included the following Libs in my application:-
LIBS+=/System/Library/Frameworks/Carbon.framework/Carbon
LIBS+=/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation

I have included the "Files.h" in my project settings:-
/System/Library/Frameworks/CoreServices.framework/CarbonCore.framework/Versions/A/Headers/Files.h

Plz help me where i am wrong??

Thanks and Regards
 
hi

In my code i have given the MessageBox but this message box is not appeared when i run the program. There is an error in FSMakeFSSpec() function. But i am still not able to get the error.


Thanks and Regards

*
 
I have checked the "err" in my code I have got the result code "-35" Which represent the "Bad volume name". I have given a full path of existing directory named "unique" on root and want to create a hello.txt file in that directory. Where i am wrong plz help me.

Thanks and Regards
 
Hi all

I have search the carbon mailing archive which suggest me to create file using the FSCreateFileUnicode() I have studied this fuction but i have got little bit confused. Plz help by giving some code example to create file using FSCreateFileUnicode().


Thanks and Regards
 
Back
Top