00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef __IOLIB_H__
00031 #define __IOLIB_H__
00032
00034
00035
00036
00037
00038
00039 #include <vector>
00040
00041
00042
00043
00044
00048 class FileException
00049 {
00050 };
00051
00052
00056 class FileWriter
00057 {
00058 public:
00059 virtual ~FileWriter() {}
00060
00061 void printf(const char *format, ...) PRINTF_VAARG_ATTRIBUTE(2, 3);
00062
00063 virtual int write(const char *data, unsigned int size) = 0;
00064 };
00065
00066
00073 FileWriter *CreateFileWriter(const std::string &filename);
00074
00078 class FileList
00079 {
00080 public:
00081 FileList() : type(0) {}
00082
00083 bool operator < (const FileList &rhs) const {
00084 if (type != rhs.type) {
00085 return type < rhs.type;
00086 }
00087 return name < rhs.name;
00088 }
00089 public:
00090 std::string name;
00091 int type;
00092 };
00093
00094
00100 class CFile
00101 {
00102 public:
00103 CFile();
00104 ~CFile();
00105
00106 int open(const char *name, long flags);
00107 int close();
00108 void flush();
00109 int read(void *buf, size_t len);
00110 int seek(long offset, int whence);
00111 long tell();
00112
00113 int printf(const char *format, ...) PRINTF_VAARG_ATTRIBUTE(2, 3);
00114 private:
00115 CFile(const CFile &rhs);
00116 const CFile &operator = (const CFile &rhs);
00117 private:
00118 class PImpl;
00119 PImpl *pimpl;
00120 };
00121
00122 enum {
00123 CLF_TYPE_INVALID,
00124 CLF_TYPE_PLAIN,
00125 CLF_TYPE_GZIP,
00126 CLF_TYPE_BZIP2
00127 };
00128
00129 #define CL_OPEN_READ 0x1
00130 #define CL_OPEN_WRITE 0x2
00131 #define CL_WRITE_GZ 0x4
00132 #define CL_WRITE_BZ2 0x8
00133
00134
00135
00136
00137
00139 extern char *LibraryFileName(const char *file, char *buffer, size_t buffersize);
00140
00141 extern bool CanAccessFile(const char *filename);
00142
00144 extern int ReadDataDirectory(const char *dirname, std::vector<FileList> &flp);
00145
00147
00148 #endif // !__IOLIB_H__