Re: Simple File System Programming in Carbon
Re: Simple File System Programming in Carbon
- Subject: Re: Simple File System Programming in Carbon
- From: Laurence Harris <email@hidden>
- Date: Tue, 16 Jan 2007 12:01:16 -0500
Please use plain text.
On Jan 16, 2007, at 11:38 AM, John Reed wrote:
Help with the File System
I'm trying to implement a standard "Save" function in my code and
am having
trouble. I had this down in OS 9, but now it seems there is more
involved a
nd I can't figure out what I'm missing.
Here's my code (I already successfully implemented a Nav dialog and
got a fi
lename in my NavReplyRecord, but all the subsequent calls require a
FSRef an
d I can't figure out where I'm supposed to get that.
// Create new file
forkNameLength = sizeof reply.saveFileName;
status = FSCreateFileUnicode( &ref, forkNameLength, (UniChar*)
reply.saveFile
Name, 0, NULL, newRef, NULL );
What on earth are you doing here with saveFileName? sizeof
( saveFileName ) == 4 because it's a pointer to an opaque data
structure, which is *not* a UniChar buffer. C-style casts like this
are truly evil. Did you bother to check the value of status after
this call?
// Open fork
status = FSOpenFork( &ref, forkNameLength, (UniChar*)
reply.saveFileName, per
missions, &forkRefNum );
The file name is not a fork name.
// Set write position
status = FSSetForkPosition( forkRefNum, positionMode,
positionOffset );
// Write data
requestCount = sizeof VELOCITY; // some test data
status = FSWriteFork( forkRefNum, positionMode, positionOffset,
requestCount
, &buffer, &actualCount );
status = FSCloseFork( forkRefNum );
THIS ISN'T WORKING - I think it's the ref field which I haven't yet
acquired.
Ah yes, guessing is so much better than doing your homework and
checking error codes.
Help would be appreciated (I've tried looking at example code but I
have a r
eal hard time following other people's code - and I don't learn as
much).
Try reading up on CFStrings and the fork APIs. Try CFString.h and
File.h for starters. Don't waste time writing code when you don't
even understand the basics.
Larry
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Filesystem-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden