FIFE  6e1afdbeda11afe9ac53e6023a4be96ef88f1dc6
dat2.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2017 by the FIFE team *
3  * http://www.fifengine.net *
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:
67  DAT2(VFS* vfs, const std::string& path);
68 
69  bool fileExists(const std::string& name) const;
70  RawData* open(const std::string& file) const;
71 
76  const RawDataDAT2::s_info& getInfo(const std::string& name) const;
77 
78  std::set<std::string> listFiles(const std::string& pathstr) const;
79  std::set<std::string> listDirectories(const std::string& pathstr) const;
80 
81  private:
82  std::string m_datpath;
83  mutable boost::scoped_ptr<RawData> m_data;
84  typedef std::map<std::string, RawDataDAT2::s_info> type_filelist;
85  mutable type_filelist m_filelist;
86 
92  mutable Timer m_timer;
93 
95  void readFileEntry() const;
96 
98  type_filelist::const_iterator findFileEntry(const std::string& name) const;
99 
100  std::set<std::string> list(const std::string& pathstr, bool dirs) const;
101 
102  // Not copyable
103  DAT2(const DAT2&);
104  DAT2& operator=(const DAT2&);
105  };
106 
107 } // FIFE
108 
109 #endif
uint32_t m_filecount
number of file entries to read
Definition: dat2.h:88
bool fileExists(const std::string &name) const
check if the given file exists
Definition: dat2.cpp:115
RawData * open(const std::string &file) const
open a file inside this source
Definition: dat2.cpp:110
The needed information for the extraction.
Definition: rawdatadat2.h:51
Timer m_timer
lazy loading timer
Definition: dat2.h:92
VFSSource abstract baseclass.
Definition: vfssource.h:46
VFSource for the Fallout2 DAT file format.
Definition: dat2.h:59
boost::scoped_ptr< RawData > m_data
Definition: dat2.h:83
type_filelist::const_iterator findFileEntry(const std::string &name) const
find a file entry
Definition: dat2.cpp:127
std::set< std::string > list(const std::string &pathstr, bool dirs) const
Definition: dat2.cpp:165
std::map< std::string, RawDataDAT2::s_info > type_filelist
Definition: dat2.h:84
std::set< std::string > listDirectories(const std::string &pathstr) const
list all directories in a directory of this source
Definition: dat2.cpp:161
const RawDataDAT2::s_info & getInfo(const std::string &name) const
Get Information needed to unpack and extract data.
Definition: dat2.cpp:119
void readFileEntry() const
read a bunch of file entries
Definition: dat2.cpp:74
uint32_t m_currentIndex
current index in file
Definition: dat2.h:90
std::set< std::string > listFiles(const std::string &pathstr) const
list all files in a directory of this source
Definition: dat2.cpp:157
the main VFS (virtual file system) class
Definition: vfs.h:58
Simple Timer class.
Definition: timer.h:61
unsigned int uint32_t
Definition: core.h:40
DAT2 & operator=(const DAT2 &)
DAT2(VFS *vfs, const std::string &path)
Constructor Create a VFSSource for a Fallout2 DAT file.
Definition: dat2.cpp:43
type_filelist m_filelist
Definition: dat2.h:85
std::string m_datpath
Definition: dat2.h:82
Used to access diffrent kinds of data.
Definition: rawdata.h:48