____ _ __
/ __ )____ _____ | | / /___ ___________
/ __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
/ /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
/_____/\____/____/ |__/|__/\__,_/_/ /____/
A futuristic real-time strategy game.
This file is part of Bos Wars.
(C) Copyright 2001-2007 by the Bos Wars and Stratagus Project.
Distributed under the "GNU General Public License"00001 // ____ _ __ 00002 // / __ )____ _____ | | / /___ ___________ 00003 // / __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/ 00004 // / /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ ) 00005 // /_____/\____/____/ |__/|__/\__,_/_/ /____/ 00006 // 00007 // A futuristic real-time strategy game. 00008 // This file is part of Bos Wars. 00009 // 00011 // 00012 // (c) Copyright 2000-2007 by Andreas Arens 00013 // 00014 // This program is free software; you can redistribute it and/or modify 00015 // it under the terms of the GNU General Public License as published by 00016 // the Free Software Foundation; only version 2 of the License. 00017 // 00018 // This program is distributed in the hope that it will be useful, 00019 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00021 // GNU General Public License for more details. 00022 // 00023 // You should have received a copy of the GNU General Public License 00024 // along with this program; if not, write to the Free Software 00025 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00026 // 02111-1307, USA. 00027 00028 #ifndef __IOLIB_H__ 00029 #define __IOLIB_H__ 00030 00032 00033 /*---------------------------------------------------------------------------- 00034 -- Includes 00035 ----------------------------------------------------------------------------*/ 00036 00037 #include <vector> 00038 #include <zlib.h> 00039 00040 class CMapInfo; 00041 00042 /*---------------------------------------------------------------------------- 00043 -- Definitons 00044 ----------------------------------------------------------------------------*/ 00045 00049 class FileException 00050 { 00051 }; 00052 00053 00057 class FileWriter 00058 { 00059 public: 00060 virtual ~FileWriter() {} 00061 00062 void printf(const char *format, ...); 00063 00064 virtual int write(const char *data, unsigned int size) = 0; 00065 }; 00066 00067 00074 FileWriter *CreateFileWriter(const std::string &filename); 00075 00076 00077 00081 class FileList { 00082 public: 00083 FileList() : name(NULL), type(0), xdata(NULL) {} 00084 00085 char *name; 00086 int type; 00087 CMapInfo *xdata; 00088 }; 00089 00090 00096 class CFile { 00097 public: 00098 CFile(); 00099 ~CFile(); 00100 00101 int open(const char *name, long flags); 00102 int close(); 00103 void flush(); 00104 int read(void *buf, size_t len); 00105 int seek(long offset, int whence); 00106 long tell(); 00107 int printf(const char *format, ...); 00108 00109 private: 00110 int cl_type; 00111 FILE *cl_plain; 00112 gzFile cl_gz; 00113 }; 00114 00115 enum { 00116 CLF_TYPE_INVALID, 00117 CLF_TYPE_PLAIN, 00118 CLF_TYPE_GZIP, 00119 }; 00120 00121 #define CL_OPEN_READ 0x1 00122 #define CL_OPEN_WRITE 0x2 00123 #define CL_WRITE_GZ 0x4 00124 00125 /*---------------------------------------------------------------------------- 00126 -- Functions 00127 ----------------------------------------------------------------------------*/ 00128 00130 extern char *LibraryFileName(const char *file, char *buffer, size_t buffersize); 00131 00133 extern int ReadDataDirectory(const char *dirname, int (*filter)(char*, FileList *), 00134 std::vector<FileList> &flp); 00135 00137 00138 #endif // !__IOLIB_H__
1.5.6