Advertisement
Ember

file.hpp

Dec 17th, 2015
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.43 KB | None | 0 0
  1. class File
  2. {
  3. public:
  4.     struct Description
  5.     {
  6.         UInt FileAttributes;
  7.         ULong CreationTime;
  8.         ULong LastAccessTime;
  9.         ULong LastWriteTime;
  10.         UInt VolumeSerialNumber;
  11.         ULong FileSize;
  12.         UInt NumberOfLinks;
  13.         ULong FileIndex;
  14.     };
  15.  
  16. public:
  17.     // Constructors
  18.     File() : FileSize(0), Data(nullptr), Size(0), Position(0), Opened(0), End(0) {};
  19.     File(const File& other) = delete;
  20.     ~File() { Close(); };
  21.  
  22.     // Stuff
  23.     enum class Mode : Byte { Read = 1, Write = 2, Overwrite = 4 };
  24.     enum class Offset : Byte { Begin, Current, End };
  25.  
  26.     // Methods
  27.     Bool Open(String filename, Mode filemode);
  28.     Description GetDescription();
  29.     Bool Allocate(UInt size);
  30.     Void Close();
  31.  
  32.     // Reading
  33.     template <typename T> T Read();
  34.     template <typename T> T* Read(UInt count);
  35.     template <typename T> Void Read(Void* buffer);
  36.     template <typename T> Void Read(Void* buffer, UInt count);
  37.     template <typename T> Void Read(Array<T> buffer, UInt count);
  38.     // -- //
  39.     String ReadWord();
  40.  
  41.     // Writing
  42.     template <typename T> Int Write(const T& data);
  43.     template <typename T> Int Write(T data, UInt count);
  44.  
  45.     // Stuffs
  46.     Void* Load(UInt count);
  47.     UInt Seek(Offset offset, UInt seek);
  48.  
  49.     // Public members
  50.     Void* Handle;
  51.     Void* Data;
  52.     UInt FileSize;
  53.     UInt Size;
  54.     UInt Position;
  55.     Bool Opened;
  56.     Bool End;
  57. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement