Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - fbwritep() write data from a pointed-to buffer to a file http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 fbwritep()          Write data from a pointed-to buffer to a file
------------------------------------------------------------------------------
 Declaration
   fileio.hdr

 Syntax
   func uint fbwritep extern
   param value _HFILE hFile, ;
         value ulong  pBuffer, ;
         value uint   uBytes

 Arguments
   hFile is the handle of the file to manipulate.

   xBuffer is a pointer to the buffer holding the data to be written to the
   file.

   uBytes is the number of bytes to write.

 Return
   The number of bytes written.

 Description
   The fbwritep() function attempts to write uBytes bytes to the
   file specified by hFile from the buffer, addressed by pBufferPtr. It
   returns the number of bytes actually transferred. If fbwritep() returns a
   value different from the value specified in uBytes, then the disk
   is full or there is a physical defect with the file. It is most likely that
   the disk is full. The file must have been opened prior to the write.

   The maximum value for uBytes is 65535 or 0xffff. If uBytes is
   specified larger than the size of the buffer with valid data,
   succeeding data will be transferred from memory to the file,
   resulting in garbage stored in the file.

   The pBuffer is usually retrieved by previously calling malloc() to
   allocate dynamic memory.

   As data is transferred to the file, DOS adjusts the read/write pointer by
   uBytes bytes. If fbwritep() writes 20 bytes, the read/write pointer of
   the file is adjusted by 20 bytes. Use fbseek() to move the read/write
   pointer without reading or writing the file.

 Example
   #define EXAMPLE_FILE
   #include example.hdr

   proc Test_fbwritep
   // Write the interrupt vector table to a file
   vardef
      ptr( byte ) pMem
      _HFILE      hFile
   enddef
   pMem := 0                                 // point to interrupt table
   if fbopen( hFile, "vect.mem", FB_CWRITE ) // open file
      fbwritep( hFile, pMem, 1024 )          // write vectors
      fbclose( hFile )                       // close file
      erase "vect.mem" // comment out for examining the file
   endif
   endproc

   proc main
   Test_fbwritep()
   endproc

See Also: fbwrite()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson