| 1 | // -------------------------------------------------------------------------- |
|---|
| 2 | // |
|---|
| 3 | // File |
|---|
| 4 | // Name: RaidFileWrite.h |
|---|
| 5 | // Purpose: Writing RAID like files |
|---|
| 6 | // Created: 2003/07/10 |
|---|
| 7 | // |
|---|
| 8 | // -------------------------------------------------------------------------- |
|---|
| 9 | |
|---|
| 10 | #ifndef RAIDFILEWRITE__H |
|---|
| 11 | #define RAIDFILEWRITE__H |
|---|
| 12 | |
|---|
| 13 | #include <string> |
|---|
| 14 | |
|---|
| 15 | #include "IOStream.h" |
|---|
| 16 | |
|---|
| 17 | class RaidFileDiscSet; |
|---|
| 18 | |
|---|
| 19 | // -------------------------------------------------------------------------- |
|---|
| 20 | // |
|---|
| 21 | // Class |
|---|
| 22 | // Name: RaidFileWrite |
|---|
| 23 | // Purpose: Writing RAID like files |
|---|
| 24 | // Created: 2003/07/10 |
|---|
| 25 | // |
|---|
| 26 | // -------------------------------------------------------------------------- |
|---|
| 27 | class RaidFileWrite : public IOStream |
|---|
| 28 | { |
|---|
| 29 | public: |
|---|
| 30 | RaidFileWrite(int SetNumber, const std::string &Filename); |
|---|
| 31 | RaidFileWrite(int SetNumber, const std::string &Filename, int refcount); |
|---|
| 32 | ~RaidFileWrite(); |
|---|
| 33 | private: |
|---|
| 34 | RaidFileWrite(const RaidFileWrite &rToCopy); |
|---|
| 35 | |
|---|
| 36 | public: |
|---|
| 37 | // IOStream interface |
|---|
| 38 | virtual int Read(void *pBuffer, int NBytes, int Timeout = IOStream::TimeOutInfinite); // will exception |
|---|
| 39 | virtual void Write(const void *pBuffer, int NBytes); |
|---|
| 40 | virtual pos_type GetPosition() const; |
|---|
| 41 | virtual void Seek(pos_type Offset, int SeekType); |
|---|
| 42 | virtual void Close(); // will discard the file! Use commit instead. |
|---|
| 43 | virtual bool StreamDataLeft(); |
|---|
| 44 | virtual bool StreamClosed(); |
|---|
| 45 | |
|---|
| 46 | // Extra bits |
|---|
| 47 | void Open(bool AllowOverwrite = false); |
|---|
| 48 | void Commit(bool ConvertToRaidNow = false); |
|---|
| 49 | void Discard(); |
|---|
| 50 | void TransformToRaidStorage(); |
|---|
| 51 | void Delete(); |
|---|
| 52 | pos_type GetFileSize(); |
|---|
| 53 | pos_type GetDiscUsageInBlocks(); |
|---|
| 54 | |
|---|
| 55 | static void CreateDirectory(int SetNumber, const std::string &rDirName, bool Recursive = false, int mode = 0777); |
|---|
| 56 | static void CreateDirectory(const RaidFileDiscSet &rSet, const std::string &rDirName, bool Recursive = false, int mode = 0777); |
|---|
| 57 | |
|---|
| 58 | private: |
|---|
| 59 | |
|---|
| 60 | private: |
|---|
| 61 | int mSetNumber; |
|---|
| 62 | std::string mFilename; |
|---|
| 63 | int mOSFileHandle; |
|---|
| 64 | int mRefCount; |
|---|
| 65 | }; |
|---|
| 66 | |
|---|
| 67 | #endif // RAIDFILEWRITE__H |
|---|
| 68 | |
|---|