25 #include <boost/bind.hpp>
44 :
VFSSource(vfs), m_datpath(file), m_data(vfs->open(file)), m_filelist() {
47 <<
"loading: " << file
48 <<
" filesize: " <<
m_data->getDataLength());
55 <<
"FileListLength: " << fileListLength
56 <<
" ArchiveSize: " << archiveSize);
58 if (archiveSize !=
m_data->getDataLength())
59 throw InvalidFormat(
"size mismatch");
61 m_data->setIndex( archiveSize - fileListLength - 8);
90 while( load_per_cycle-- ) {
122 throw NotFound(name);
133 std::string name = path;
136 if (name.find(
"./") == 0) {
140 type_filelist::const_iterator i =
m_filelist.find(name);
146 <<
"Missing '" << name
158 return list(pathstr,
false);
162 return list(pathstr,
true);
165 std::set<std::string>
DAT2::list(
const std::string& pathstr,
bool dirs)
const {
166 std::set<std::string>
list;
167 std::string path = pathstr;
177 if (path.find(
"./") == 0) {
181 size_t lastIndex = path.size();
182 if (lastIndex != 0 && path[lastIndex-1] !=
'/') {
186 type_filelist::const_iterator end =
m_filelist.end();
187 for (type_filelist::const_iterator i =
m_filelist.begin(); i != end; ++i) {
188 const std::string& file = i->first;
189 if (file.find(path) == 0) {
190 std::string cleanedfile = file.substr(path.size(), file.size());
191 bool isdir = cleanedfile.find(
'/') != std::string::npos;
194 cleanedfile = cleanedfile.substr(0, cleanedfile.find(
'/'));
195 if (cleanedfile.find(
'/') != cleanedfile.rfind(
'/')) {
202 list.insert(cleanedfile);
uint32_t m_filecount
number of file entries to read
bool fileExists(const std::string &name) const
check if the given file exists
RawData * open(const std::string &file) const
open a file inside this source
The needed information for the extraction.
Timer m_timer
lazy loading timer
Helper class to create log strings out from separate parts Usage: LMsg("some text") << variable << "...
VFSSource abstract baseclass.
VFS * getVFS() const
get the VFS this source is associated with.
static Logger _log(LM_AUDIO)
boost::scoped_ptr< RawData > m_data
void setInterval(int32_t msec)
Set the interval in milliseconds.
type_filelist::const_iterator findFileEntry(const std::string &name) const
find a file entry
void start()
Start the timer.
std::set< std::string > list(const std::string &pathstr, bool dirs) const
A subclass of RawDataMemSource, that fills itself with a FALLOUT1 .DAT file entry.
std::set< std::string > listDirectories(const std::string &pathstr) const
list all directories in a directory of this source
const RawDataDAT2::s_info & getInfo(const std::string &name) const
Get Information needed to unpack and extract data.
void readFileEntry() const
read a bunch of file entries
uint32_t m_currentIndex
current index in file
#define FL_LOG(logger, msg)
std::set< std::string > listFiles(const std::string &pathstr) const
list all files in a directory of this source
void stop()
Stop the timer.
the main VFS (virtual file system) class
std::string fixPath(std::string path) const
DAT2(VFS *vfs, const std::string &path)
Constructor Create a VFSSource for a Fallout2 DAT file.
void setCallback(const type_callback &callback)
Set the callback that will be called.
Used to access diffrent kinds of data.