home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 June / PCFJune.iso / Xenon / XenonSource.exe / gamesystem / includes / gs_file.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-10  |  1.9 KB  |  80 lines

  1. //-------------------------------------------------------------
  2. //
  3. // Class:    gsCFile
  4. //
  5. // Author:    John M Phillips
  6. //
  7. // Started:    12/03/00
  8. //
  9. // Base:    CObject
  10. //
  11. // Derived:    None
  12. //
  13. //-------------------------------------------------------------
  14.  
  15. #ifndef _INCLUDE_GS_FILE_H
  16. #define _INCLUDE_GS_FILE_H
  17.  
  18. #include "gs_types.h"
  19. #include "gs_object.h"
  20.  
  21. //-------------------------------------------------------------
  22. // File Access Mode
  23.  
  24. typedef enum {
  25.     gsFILE_READ,                    // read from an existing file
  26.     gsFILE_WRITE,                    // write to a new file
  27. } gsFileMode;
  28.  
  29. //-------------------------------------------------------------
  30. // Error codes
  31.  
  32. const gsUDWORD gsFILE_READ_FAILED = 0xFFFFFFFF;
  33. const gsUDWORD gsFILE_WRITE_FAILED = 0xFFFFFFFF;
  34.  
  35. //-------------------------------------------------------------
  36.  
  37. class gsCFile : public gsCObject
  38. {
  39.     private:
  40.         HANDLE m_handle;
  41.         gsFileMode m_mode;
  42.  
  43.         static char m_directory_name[_MAX_PATH];
  44.  
  45.     public:
  46.         gsCFile();
  47.         virtual ~gsCFile();
  48.  
  49.         static bool setDirectory(const char *directory_name);
  50.         static bool getFullName(const char *filename,char *fullname);
  51.         static const char *findFirst(const char *search_string);
  52.         static const char *findNext();
  53.         static void findClose();
  54.         static bool exists(const char *filename);
  55.  
  56.         bool open(const char *filename,gsFileMode mode = gsFILE_READ);
  57.         void close();
  58.  
  59.         bool isOpen();
  60.         gsFileMode getMode();
  61.         bool isEndOfFile();
  62.  
  63.         gsUDWORD getLength();
  64.         gsUDWORD getPosition();
  65.         bool setPosition(gsUDWORD position);
  66.  
  67.         gsUDWORD getByte();
  68.         bool putByte(gsUBYTE byte);
  69.  
  70.         gsUDWORD read(void *buffer,gsUDWORD byte_count);
  71.         gsUDWORD write(void *buffer,gsUDWORD byte_count);
  72.  
  73.         gsUDWORD readString(char *buffer,int max_length);
  74.         gsUDWORD __cdecl writeString(const char *format,...);
  75. };
  76.  
  77. //-------------------------------------------------------------
  78.  
  79. #endif
  80.