[comp.sys.mac.programmer] problems with FSWrite

lamont@convex.com (Bradley Lamont) (06/24/91)

I am hoping someone can help me with this problem. I am running on a
Mac SE w/2.5 meg and a 20 meg drive under system 7.0.  I am running
Think C 4.0.5.

I can't get the FSWrite command to work.  I use SFGetFile to get a filename
and number, create the file, open it, and then try to write an array to it.

The first 3 commands (FSCreate,FSOpen,FSSetFPos) return error codes of 0 meaning
the operation was successful (right??).  When I use FSWrite, it returns a
code of -34 (Disk full).  I know I have over 2 meg free on the drive.

I then quit out of my program back into Think C and when I try to quit, 
edit, or do any disk operation, my SE crashes and reboots (I have Macsbug
running and it the crash doesn't even fall into Macsbug, it just reboots)

The code is similiar to:

   SFPutFile (dlgOrigin, "\pSave under what name?", "\p", NIL, &theReply);
   if (theReply.good)
      {
         resultCode = Create (theReply.fName, theReply.vRefNum,
                               'BLKI', 'STNT');                               
         /* resultCode = 0 at this point */

         resultCode = FSOpen (theReply.fName, theReply.vRefNum, &theFile);
         /* again resultCode = 0 */

         resultCode = SetFPos (theFile, fsFromStart, 0);
         /* resultCode = 0 */

         resultCode = FSWrite (theFile, STUNT_FILE_SIZE, (**wData).map);
         /* resultCode = -34 */
      }

I have HLocked wData in the heap, map is an array[29][38], and
STUNT_FILE_SIZE is 29*38=1102.

Can anyone please help me?
Please respond by e-mail.

Thanks,
Brad Lamont

lamont@trojan.convex.com   Convex Computer Corp.
lamont@ux1.cso.uiuc.edu    The University of Illinois at Urbana/Champaign