Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Creation of a file using FSpCreate()??

Creation of a file using FSpCreate()??
Thread Tools
Fresh-Faced Recruit
Join Date: Jun 2005
Status: Offline
Reply With Quote
Aug 9, 2005, 05:59 AM
 
Hi
Now i am using the function FSMakeFSSpec to get a valid FSSpec but still file is not created. I have made 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 in my application:-
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

When i am compiling the program there is no error but file is not created.
Plz help me where i am wrong??
Thanks and Regards
     
Mac Enthusiast
Join Date: Nov 2003
Status: Offline
Reply With Quote
Aug 9, 2005, 11:51 AM
 
A few things:

1) You're only checking for "fnfErr" so you actually don't know that there is "no error" (there in fact is one, which is why FSpCreate is not working here);
2) Relative paths in FSMakeFSSpec are not specified with "/" but with ":" (FSMakeFSSpec is a File Manager call, which was around before OS X. It's been Carbonized, but it hasn't been rewritten, thus the use of OS 9 era path separators);
3) You should be using FSMakeFSRefUnicode and FSRefs (instead of FSSpecs). FSMakeFSSpec is deprecated in 10.4.x.
     
darpan  (op)
Fresh-Faced Recruit
Join Date: Jun 2005
Status: Offline
Reply With Quote
Aug 10, 2005, 05:23 AM
 
Hi

Actually I am writting a program to recover a file from a crashed Apple Macintosh Disk having HFS or HFS+ file system. I have enough knowledge of HFS and HFS+ file system. All is well in my program now i am on saving part a file.

I know Where the Data Fork and Resource Fork sectors or clusters of a file lies on the Hard Disk. I am able to raw read those particular sectors for crashed hard disk.

I want to Create a file and then open the Data Fork of created file and Write the data fork data from crashed hard disk and then open the Resource Fork of created file and Write the resource fork data from the crashed hard disk and then close the file.

I have made 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 in my application:-
OSErr err;
FSSpec spec;
err=FSMakeFSSpec(0,0,":unique:hello.txt",&spec );
if(err != fnfErr)
{
//Display message and exit
}

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

When i am compiling the program there is no error but file is not created.

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.


How i can use FSMakeFSRefUnicode and FSRefs (instead of FSSpecs). Plz give example code if any.

Thanks and Regards
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Aug 10, 2005, 11:57 AM
 
You have already asked this question 3 times on carbon-dev.
     
Mac Enthusiast
Join Date: Nov 2003
Status: Offline
Reply With Quote
Aug 10, 2005, 10:40 PM
 
Well for one thing, FSMakeFSSpec takes a Pascal string (not a C string) for its "name" argument.
     
darpan  (op)
Fresh-Faced Recruit
Join Date: Jun 2005
Status: Offline
Reply With Quote
Aug 11, 2005, 01:55 AM
 
Hi

I have changed the code to:- err=FSMakeFSSpec(0,0,"\punique:hello.txt",&spe c); but i am getting the same error code =-35 Which represent the "Bad volume name".

Thanks and Regards
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Aug 11, 2005, 02:00 AM
 
Have you looked into specifying a volume name and/or identifier?
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
darpan  (op)
Fresh-Faced Recruit
Join Date: Jun 2005
Status: Offline
Reply With Quote
Aug 12, 2005, 08:16 AM
 
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
     
Mac Enthusiast
Join Date: Nov 2003
Status: Offline
Reply With Quote
Aug 12, 2005, 11:43 AM
 
The answer to your specific question concerning FSCreateFileUnicode can be found here.

The answers to all your questions (including future ones you might have) about creating files can be found here.

And sample code with examples of the APIs described in all this documentation can be found here.
     
   
Thread Tools
Forum Links
Forum 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
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:25 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2