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 #ifdef USE_ZLIB
00042 #include <zlib.h>
00043 #endif
00044
00045 #ifdef USE_BZ2LIB
00046 #include <bzlib.h>
00047 #endif
00048
00049 class CMapInfo;
00050
00051
00052
00053
00054
00058 class FileException
00059 {
00060 };
00061
00062
00066 class FileWriter
00067 {
00068 public:
00069 virtual ~FileWriter() {}
00070
00071 void printf(const char *format, ...);
00072
00073 virtual int write(const char *data, unsigned int size) = 0;
00074 };
00075
00076
00083 FileWriter *CreateFileWriter(const std::string &filename);
00084
00085
00086
00090 class FileList {
00091 public:
00092 FileList() : name(NULL), type(0), xdata(NULL) {}
00093
00094 char *name;
00095 int type;
00096 CMapInfo *xdata;
00097 };
00098
00099
00105 class CFile {
00106 public:
00107 CFile();
00108 ~CFile();
00109
00110 int open(const char *name, long flags);
00111 int close();
00112 void flush();
00113 int read(void *buf, size_t len);
00114 int seek(long offset, int whence);
00115 long tell();
00116 int printf(const char *format, ...);
00117
00118 private:
00119 int cl_type;
00120 FILE *cl_plain;
00121 #ifdef USE_ZLIB
00122 gzFile cl_gz;
00123 #endif // !USE_ZLIB
00124 #ifdef USE_BZ2LIB
00125 BZFILE *cl_bz;
00126 #endif // !USE_BZ2LIB
00127 };
00128
00129 enum {
00130 CLF_TYPE_INVALID,
00131 CLF_TYPE_PLAIN,
00132 CLF_TYPE_GZIP,
00133 CLF_TYPE_BZIP2
00134 };
00135
00136 #define CL_OPEN_READ 0x1
00137 #define CL_OPEN_WRITE 0x2
00138 #define CL_WRITE_GZ 0x4
00139 #define CL_WRITE_BZ2 0x8
00140
00141
00142
00143
00144
00146 extern char *LibraryFileName(const char *file, char *buffer, size_t buffersize);
00147
00149 extern int ReadDataDirectory(const char *dirname, int (*filter)(char*, FileList *),
00150 std::vector<FileList> &flp);
00151
00153
00154 #endif // !__IOLIB_H__