_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
                   Stratagus - A free fantasy real time strategy game engine

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
iolib.h
Go to the documentation of this file.
1 // _________ __ __
2 // / _____// |_____________ _/ |______ ____ __ __ ______
3 // \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
4 // / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
5 // /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
6 // \/ \/ \//_____/ \/
7 // ______________________ ______________________
8 // T H E W A R B E G I N S
9 // Stratagus - A free fantasy real time strategy game engine
10 //
12 //
13 // (c) Copyright 2000-2005 by Andreas Arens
14 //
15 // This program is free software; you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation; only version 2 of the License.
18 //
19 // This program is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 // GNU General Public License for more details.
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program; if not, write to the Free Software
26 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 // 02111-1307, USA.
28 //
29 
30 #ifndef __IOLIB_H__
31 #define __IOLIB_H__
32 
34 
35 /*----------------------------------------------------------------------------
36 -- Includes
37 ----------------------------------------------------------------------------*/
38 
39 #include <vector>
40 
41 /*----------------------------------------------------------------------------
42 -- Definitons
43 ----------------------------------------------------------------------------*/
44 
49 {
50 };
51 
52 
57 {
58 public:
59  virtual ~FileWriter() {}
60 
61  void printf(const char *format, ...) PRINTF_VAARG_ATTRIBUTE(2, 3); // Don't forget to count this
62 
63  virtual int write(const char *data, unsigned int size) = 0;
64 };
65 
66 
73 FileWriter *CreateFileWriter(const std::string &filename);
74 
78 class FileList
79 {
80 public:
81  FileList() : type(0) {}
82 
83  bool operator < (const FileList &rhs) const
84  {
85  if (type != rhs.type) {
86  return type < rhs.type;
87  }
88  return name < rhs.name;
89  }
90 public:
91  std::string name;
92  int type;
93 };
94 
95 
101 class CFile
102 {
103 public:
104  CFile();
105  ~CFile();
106 
107  int open(const char *name, long flags);
108  int close();
109  void flush();
110  int read(void *buf, size_t len);
111  int seek(long offset, int whence);
112  long tell();
113 
114  int printf(const char *format, ...) PRINTF_VAARG_ATTRIBUTE(2, 3); // Don't forget to count this
115 private:
116  CFile(const CFile &rhs); // No implementation
117  const CFile &operator = (const CFile &rhs); // No implementation
118 private:
119  class PImpl;
120  PImpl *pimpl;
121 };
122 
123 enum {
128 };
129 
130 #define CL_OPEN_READ 0x1
131 #define CL_OPEN_WRITE 0x2
132 #define CL_WRITE_GZ 0x4
133 #define CL_WRITE_BZ2 0x8
134 
135 /*----------------------------------------------------------------------------
136 -- Functions
137 ----------------------------------------------------------------------------*/
138 
140 extern std::string LibraryFileName(const char *file);
141 
142 extern bool CanAccessFile(const char *filename);
143 
145 extern int ReadDataDirectory(const char *dirname, std::vector<FileList> &flp);
146 
148 
149 #endif // !__IOLIB_H__
FileWriter * CreateFileWriter(const std::string &filename)
Definition: iolib.cpp:787
gzip file handle
Definition: iolib.h:127
#define PRINTF_VAARG_ATTRIBUTE(a, b)
Definition: stratagus.h:90
FileList()
Definition: iolib.h:81
int type
Name of the file.
Definition: iolib.h:92
Definition: iolib.h:101
Definition: iolib.h:56
Definition: iolib.h:48
bool CanAccessFile(const char *filename)
Definition: iolib.cpp:639
int ReadDataDirectory(const char *dirname, std::vector< FileList > &flp)
Read the contents of a directory.
Definition: iolib.cpp:658
std::string name
Definition: iolib.h:91
void virtual int write(const char *data, unsigned int size)=0
std::string LibraryFileName(const char *file)
Build library path name.
Definition: iolib.cpp:632
Definition: iolib.cpp:58
void printf(const char *format,...) PRINTF_VAARG_ATTRIBUTE(2
Definition: iolib.cpp:720
Definition: iolib.h:78
Definition: iolib.h:124
plain text file handle
Definition: iolib.h:126
virtual ~FileWriter()
Definition: iolib.h:59
invalid file handle
Definition: iolib.h:125
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.