FIFE  2008.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
dat2.h
1 /***************************************************************************
2  * Copyright (C) 2005-2008 by the FIFE team *
3  * http://www.fifengine.de *
4  * This file is part of FIFE. *
5  * *
6  * FIFE is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU Lesser General Public *
8  * License as published by the Free Software Foundation; either *
9  * version 2.1 of the License, or (at your option) any later version. *
10  * *
11  * This library is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14  * Lesser General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Lesser General Public *
17  * License along with this library; if not, write to the *
18  * Free Software Foundation, Inc., *
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20  ***************************************************************************/
21 
22 #ifndef FIFE_MAP_LOADERS_FALLOUT_DAT2_H
23 #define FIFE_MAP_LOADERS_FALLOUT_DAT2_H
24 
25 // Standard C++ library includes
26 #include <map>
27 #include <string>
28 
29 // Platform specific includes
30 #include "util/base/fife_stdint.h"
31 
32 // 3rd party library includes
33 #include <boost/scoped_ptr.hpp>
34 
35 // FIFE includes
36 // These includes are split up in two parts, separated by one empty line
37 // First block: files included from the FIFE root src directory
38 // Second block: files included from the same folder
39 #include "util/time/timer.h"
40 #include "vfs/vfs.h"
41 #include "vfs/vfssource.h"
42 
43 #include "rawdatadat2.h"
44 
45 namespace FIFE {
46  class RawData;
47 
59  class DAT2 : public VFSSource {
60 
61  public:
66  DAT2(VFS* vfs, const std::string& path);
67 
68  bool fileExists(const std::string& name) const;
69  RawData* open(const std::string& file) const;
70 
75  const RawDataDAT2::s_info& getInfo(const std::string& name) const;
76 
77  std::set<std::string> listFiles(const std::string& pathstr) const;
78  std::set<std::string> listDirectories(const std::string& pathstr) const;
79 
80  private:
81  std::string m_datpath;
82  mutable boost::scoped_ptr<RawData> m_data;
83  typedef std::map<std::string, RawDataDAT2::s_info> type_filelist;
84  mutable type_filelist m_filelist;
85 
87  mutable uint32_t m_filecount;
89  mutable uint32_t m_currentIndex;
91  mutable Timer m_timer;
92 
94  void readFileEntry() const;
95 
97  type_filelist::const_iterator findFileEntry(const std::string& name) const;
98 
99  std::set<std::string> list(const std::string& pathstr, bool dirs) const;
100 
101  // Not copyable
102  DAT2(const DAT2&);
103  DAT2& operator=(const DAT2&);
104  };
105 
106 } // FIFE
107 
108 #endif
bool fileExists(const std::string &name) const
Definition: dat2.cpp:112
RawData * open(const std::string &file) const
Definition: dat2.cpp:107
std::set< std::string > listDirectories(const std::string &pathstr) const
Definition: dat2.cpp:158
const RawDataDAT2::s_info & getInfo(const std::string &name) const
Definition: dat2.cpp:116
std::set< std::string > listFiles(const std::string &pathstr) const
Definition: dat2.cpp:154
Definition: vfs.h:58
DAT2(VFS *vfs, const std::string &path)
Definition: dat2.cpp:40