| 1 | // -------------------------------------------------------------------------- |
|---|
| 2 | // |
|---|
| 3 | // File |
|---|
| 4 | // Name: RaidFileRead.h |
|---|
| 5 | // Purpose: Read Raid like Files |
|---|
| 6 | // Created: 2003/07/13 |
|---|
| 7 | // |
|---|
| 8 | // -------------------------------------------------------------------------- |
|---|
| 9 | |
|---|
| 10 | #ifndef RAIDFILEREAD__H |
|---|
| 11 | #define RAIDFILEREAD__H |
|---|
| 12 | |
|---|
| 13 | #include <cstring> |
|---|
| 14 | #include <cstdlib> |
|---|
| 15 | #include <memory> |
|---|
| 16 | #include <vector> |
|---|
| 17 | |
|---|
| 18 | #include "IOStream.h" |
|---|
| 19 | |
|---|
| 20 | class RaidFileDiscSet; |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | // -------------------------------------------------------------------------- |
|---|
| 24 | // |
|---|
| 25 | // Class |
|---|
| 26 | // Name: RaidFileRead |
|---|
| 27 | // Purpose: Read RAID like files |
|---|
| 28 | // Created: 2003/07/13 |
|---|
| 29 | // |
|---|
| 30 | // -------------------------------------------------------------------------- |
|---|
| 31 | class RaidFileRead : public IOStream |
|---|
| 32 | { |
|---|
| 33 | protected: |
|---|
| 34 | RaidFileRead(int SetNumber, const std::string &Filename); |
|---|
| 35 | public: |
|---|
| 36 | virtual ~RaidFileRead(); |
|---|
| 37 | private: |
|---|
| 38 | RaidFileRead(const RaidFileRead &rToCopy); |
|---|
| 39 | |
|---|
| 40 | public: |
|---|
| 41 | // Open a raid file |
|---|
| 42 | static std::auto_ptr<RaidFileRead> Open(int SetNumber, const std::string &Filename, int64_t *pRevisionID = 0, int BufferSizeHint = 4096); |
|---|
| 43 | |
|---|
| 44 | // Extra info |
|---|
| 45 | virtual pos_type GetFileSize() const = 0; |
|---|
| 46 | |
|---|
| 47 | // Utility functions |
|---|
| 48 | static bool FileExists(int SetNumber, const std::string &rFilename, int64_t *pRevisionID = 0); |
|---|
| 49 | static bool DirectoryExists(const RaidFileDiscSet &rSet, const std::string &rDirName); |
|---|
| 50 | static bool DirectoryExists(int SetNumber, const std::string &rDirName); |
|---|
| 51 | enum |
|---|
| 52 | { |
|---|
| 53 | DirReadType_FilesOnly = 0, |
|---|
| 54 | DirReadType_DirsOnly = 1 |
|---|
| 55 | }; |
|---|
| 56 | static bool ReadDirectoryContents(int SetNumber, const std::string &rDirName, int DirReadType, std::vector<std::string> &rOutput); |
|---|
| 57 | |
|---|
| 58 | // Common IOStream interface implementation |
|---|
| 59 | virtual void Write(const void *pBuffer, int NBytes); |
|---|
| 60 | virtual bool StreamClosed(); |
|---|
| 61 | virtual pos_type BytesLeftToRead(); |
|---|
| 62 | |
|---|
| 63 | pos_type GetDiscUsageInBlocks(); |
|---|
| 64 | |
|---|
| 65 | typedef int64_t FileSizeType; |
|---|
| 66 | |
|---|
| 67 | protected: |
|---|
| 68 | int mSetNumber; |
|---|
| 69 | std::string mFilename; |
|---|
| 70 | }; |
|---|
| 71 | |
|---|
| 72 | #endif // RAIDFILEREAD__H |
|---|
| 73 | |
|---|