The macosxhints Forums

The macosxhints Forums (http://hintsforums.macworld.com/index.php)
-   OS X Developer (http://hintsforums.macworld.com/forumdisplay.php?f=27)
-   -   creation of a file through programming???? (http://hintsforums.macworld.com/showthread.php?t=41293)

darpan 08-10-2005 12:42 AM

Quote:

Originally Posted by hayne
You don't seem to be checking the return value (error code) from FSpCreate.
I'm guessing that there is an error that is preventing the creation of the file.


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

darpan 08-10-2005 02:00 AM

hi

I have checked the "err" in my code I have got the result code "-37" Which represent the "Bad filename or 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

hayne 08-10-2005 02:36 AM

I have no experience with this, but googling for:
FSMakeFSSpec example
gave several useful pages, including this one:
http://www.macosx.com/forums/archive...p/t-73850.html
that shows that the problem is that the file path needs to be specified using traditional Macintosh conventions, not Unix conventions. E.g. the folder separator is ":" instead of "/".

darpan 08-10-2005 07:31 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

hayne 08-10-2005 10:14 AM

Quote:

Originally Posted by darpan
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.

I'm not familiar enough with the traditional Mac path name conventions to be sure what is going wrong. But I recall that traditional Mac paths start with the name of the hard drive. The error message you report ("Bad volume name") suggests that it doesn't like the path starting with a ":".

I have no example code to provide (having never done this - I have only programmed in Cocoa and never dealt with resource forks) but I see in that web page I referred to above that people are recommending the Apple-supplied example file "MoreFiles". This is on the Apple developer web site, in the section for sample code.

darpan 08-12-2005 09:15 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

hayne 08-12-2005 02:53 PM

It is quite unlikely that you will get the sort of example code you are looking for here. You should search Apple's sample code pages and use Google to search for the specific functions you are looking for - that would be a much more fruitful way.


All times are GMT -5. The time now is 06:02 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.