Creation of a file using FSpCreate()??


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
unsigned char filename[64]="Aman";;
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.


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 I am trying to make a text file using programming.

I have used the following code:-

OSErr err;
FSSpec spec;
if(err == fnfErr)
QMessageBox::information(0, "message","hiiiiiiiiii");

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

I have included the following Libs in my application:-

I have included the "Files.h" in my project settings:-

Plz help me where i am wrong??

Thanks and Regards

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