 |
 |
Creation of a file using FSpCreate()??
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Jun 2005
Status:
Offline
|
|
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
|
|
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.
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Jun 2005
Status:
Offline
|
|
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
|
|
You have already asked this question 3 times on carbon-dev.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Nov 2003
Status:
Offline
|
|
Well for one thing, FSMakeFSSpec takes a Pascal string (not a C string) for its "name" argument.
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Jun 2005
Status:
Offline
|
|
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
|
|
Have you looked into specifying a volume name and/or identifier?
|
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Jun 2005
Status:
Offline
|
|
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
|
|
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.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|