home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 40 / IOPROG_40.ISO / SOFT / NETFrameworkSDK.exe / comsdk.cab / samples1.exe / smc / outfile.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-23  |  2.7 KB  |  91 lines

  1. /*****************************************************************************/
  2. #ifndef _OUTFILE_H_
  3. #define _OUTFILE_H_
  4. /*****************************************************************************
  5.  *
  6.  *  A bufferred file write class.
  7.  */
  8.  
  9. class   outFile;
  10. typedef outFile *   OutFile;
  11.  
  12. class   outFile
  13. {
  14. private:
  15.  
  16.     Compiler        outFileComp;
  17.  
  18.     char            outFileName[_MAX_PATH];
  19.     int             outFileHandle;
  20.  
  21.     bool            outFileBuffAlloc;   // did we allocate output buffer?
  22.  
  23.     size_t          outFileBuffSize;    // size    of outout buffer
  24.     char    *       outFileBuffAddr;    // address of output buffer
  25.  
  26.     char    *       outFileBuffNext;    // address of next free byte
  27.     char    *       outFileBuffLast;    // address of last free byte
  28.  
  29.     __uint32        outFileBuffOffs;    // current buffer offs within file
  30.  
  31.     void            outFileFlushBuff();
  32.  
  33. public:
  34.  
  35.     void            outFileOpen(Compiler        comp,
  36.                                 const char *    name,
  37.                                 bool            tempFile = false,
  38.                                 size_t          buffSize = 0,
  39.                                 char *          buffAddr = NULL);
  40.  
  41. #ifdef  DLL
  42.     void            outFileOpen(Compiler        comp,
  43.                                 void        *   dest);
  44. #endif
  45.  
  46.     void            outFileClose();
  47.  
  48.     void            outFileDone(bool delFlag = false);
  49.  
  50.     const char *    outFilePath()
  51.     {
  52.         return  outFileName;
  53.     }
  54.  
  55.     void            outFileWriteData(const void *   data,
  56.                                      size_t         size);
  57.  
  58. #ifdef  OLD_IL
  59.     void            outFilePatchByte(unsigned long  offset,
  60.                                      int            newVal);
  61.     void            outFilePatchData(unsigned long  offset,
  62.                                      const void *   data,
  63.                                      size_t         size);
  64. #endif
  65.  
  66.     void            outFileWritePad (size_t         size);
  67.  
  68.     void            outFileWriteByte(int x)
  69.     {
  70.         assert(outFileBuffNext >= outFileBuffAddr);
  71.         assert(outFileBuffNext <  outFileBuffLast);
  72.  
  73.         *outFileBuffNext++ = x;
  74.  
  75.         if  (outFileBuffNext == outFileBuffLast)
  76.             outFileFlushBuff();
  77.  
  78.         assert(outFileBuffNext >= outFileBuffAddr);
  79.         assert(outFileBuffNext <  outFileBuffLast);
  80.     }
  81.  
  82.     __uint32        outFileOffset()
  83.     {
  84.         return  outFileBuffOffs + (outFileBuffNext - outFileBuffAddr);
  85.     }
  86. };
  87.  
  88. /*****************************************************************************/
  89. #endif
  90. /*****************************************************************************/
  91.