diff --git a/doomsday/engine/portable/include/abstractfile.h b/doomsday/engine/portable/include/abstractfile.h index f18c7adb1a..d16470f8ab 100644 --- a/doomsday/engine/portable/include/abstractfile.h +++ b/doomsday/engine/portable/include/abstractfile.h @@ -65,6 +65,21 @@ class PathDirectoryNode; */ class AbstractFile { +public: + /// Categorization flags. + enum Flag + { + /// Flagged as having been loaded during the game startup process. + Startup = 0x1, + + /// Flagged as a non-original game resource. + Custom = 0x2, + + /// All resources are by default flagged as "custom". + DefaultFlags = Custom + }; + Q_DECLARE_FLAGS(Flags, Flag) + private: AbstractFile(); @@ -134,7 +149,7 @@ class AbstractFile /// Mark this resource as "custom". AbstractFile& setCustom(bool yes); - DFile* handle(); + DFile& handle(); /** * Access interfaces: @@ -310,11 +325,8 @@ class AbstractFile /// @see filetype_t filetype_t type_; - struct abstractfile_flags_s - { - uint startup:1; ///< Loaded during the startup process. - uint custom:1; /// < Not an original game resource. - } flags; + /// Categorization flags. + Flags flags; /// Absolute variable-length path in the vfs. ddstring_t path_; @@ -326,6 +338,8 @@ class AbstractFile uint order; }; +Q_DECLARE_OPERATORS_FOR_FLAGS(AbstractFile::Flags) + } // namespace de extern "C" { diff --git a/doomsday/engine/portable/include/dfilebuilder.h b/doomsday/engine/portable/include/dfilebuilder.h index 99e7d47de7..8459f9557a 100644 --- a/doomsday/engine/portable/include/dfilebuilder.h +++ b/doomsday/engine/portable/include/dfilebuilder.h @@ -81,11 +81,6 @@ extern "C" { /// @return File object represented by this handle. struct abstractfile_s* DFile_File(DFile* hndl); -/// @return FileList object which owns this handle. -struct filelist_s* DFile_List(DFile* hndl); - -DFile* DFile_SetList(DFile* hndl, struct filelist_s* list); - /// @return File object represented by this handle. struct abstractfile_s* DFile_File_const(DFile const* hndl); diff --git a/doomsday/engine/portable/include/fs_main.h b/doomsday/engine/portable/include/fs_main.h index 310163f0aa..b0e2a285c6 100644 --- a/doomsday/engine/portable/include/fs_main.h +++ b/doomsday/engine/portable/include/fs_main.h @@ -39,306 +39,313 @@ #ifdef __cplusplus #include - -#include "fileid.h" -#include "lumpindex.h" #include "lumpinfo.h" -namespace de { - -typedef QList FileList; - /** - * Internally the lump index has two parts: the Primary index (which is populated - * with lumps from loaded data files) and the Auxiliary index (used to temporarily - * open a file that is not considered part of the filesystem). - * - * Functions that don't know the absolute/logical lumpnum of file will have to check - * both indexes (e.g., FS::lumpNumForName()). + * @defgroup fs File System */ -class FS -{ -public: - FS(); - - ~FS(); - - /// Register the console commands, variables, etc..., of this module. - static void consoleRegister(); - - /** - * @post No more WADs will be loaded in startup mode. - */ - void endStartup(); - - /** - * Remove all file records flagged Runtime. - * @return Number of records removed. - */ - int reset(); - - /** - * (Re-)Initialize the path mappings. - */ - void initPathMap(); - - /** - * Add a new path mapping from source to destination in the vfs. - * @note Paths will be transformed into absolute paths if needed. - */ - void mapPath(char const* source, char const* destination); - - /** - * (Re-)Initialize the path => lump mappings. - * @note Should be called after WADs have been processed. - */ - void initLumpPathMap(); - - /** - * Add a new lump mapping so that @a lumpName becomes visible as @a symbolicPath - * throughout the vfs. - * @note @a symbolicPath will be transformed into an absolute path if needed. - */ - void mapPathToLump(char const* symbolicPath, char const* lumpName); - - /** - * Reset known fileId records so that the next time F_CheckFileId() is - * called on a file, it will pass. - */ - void resetFileIds(); - - /** - * Maintains a list of identifiers already seen. - * - * @return @c true if the given file can be opened, or - * @c false, if it has already been opened. - */ - bool checkFileId(char const* path); - - /** - * @return @c true if a file exists at @a path which can be opened for reading. - */ - bool accessFile(char const* path); - - /** - * @return The time when the file was last modified, as seconds since - * the Epoch else zero if the file is not found. - */ - uint lastModified(char const* fileName); - - /** - * Files with a .wad extension are archived data files with multiple 'lumps', - * other files are single lumps whose base filename will become the lump name. - * - * @param path Path to the file to be opened. Either a "real" file in the local - * file system, or a "virtual" file in the virtual file system. - * @param baseOffset Offset from the start of the file in bytes to begin. - * - * @return Newly added file instance if the operation is successful, else @c NULL. - */ - AbstractFile* addFile(char const* path, size_t baseOffset = 0); - - /// @note All files are added with baseOffset = @c 0. - int addFiles(char const* const* paths, int num); - - /** - * Attempt to remove a file from the virtual file system. - * - * @param permitRequired @c true= allow removal of resources marked as "required" - * by the currently loaded Game. - * @return @c true if the operation is successful. - */ - bool removeFile(char const* path, bool permitRequired = false); - - int removeFiles(char const* const* paths, int num, bool permitRequired = false); - - /** - * Find a lump in the Zip LumpIndex. - * - * @param path Path to search for. Relative paths are made absolute if necessary. - * @param lumpIdx If not @c NULL the translated lumpnum within the owning file object is written here. - * @return File system object representing the file which contains the found lump else @c NULL. - */ - AbstractFile* findLumpFile(char const* path, int* lumpIdx = 0); - - /// @return Number of lumps in the currently active LumpIndex. - int lumpCount(); - - bool isValidLumpNum(lumpnum_t absoluteLumpNum); - - lumpnum_t lumpNumForName(char const* name, bool silent = true); - - char const* lumpName(lumpnum_t absoluteLumpNum); - - /** - * Given a logical @a lumpnum retrieve the associated file object. - * - * @post The active LumpIndex may have changed! - * - * @param absoluteLumpNum Logical lumpnum associated to the file being looked up. - * @param lumpIdx If not @c NULL the translated lumpnum within the owning - * file object is written here. - * - * @return Found file object else @c NULL - */ - AbstractFile* lumpFile(lumpnum_t absoluteLumpNum, int* lumpIdx = 0); - - // Convenient lookup method for when only the path is needed from the source file. - inline char const* lumpFilePath(lumpnum_t absoluteLumpNum) { - if(AbstractFile* file = lumpFile(absoluteLumpNum)) return Str_Text(file->path()); - return ""; - } - - // Convenient lookup method for when only the custom property is needed from the source file. - bool lumpFileHasCustom(lumpnum_t absoluteLumpNum) { - if(AbstractFile* file = lumpFile(absoluteLumpNum)) return file->hasCustom(); - return false; - } - - /** - * Retrieve the LumpInfo metadata structure for a lump. - * - * @post The active LumpIndex may have changed! - * - * @param absoluteLumpNum Logical lumpnum associated to the file being looked up. - * @param lumpIdx If not @c NULL the translated lumpnum within the owning - * file object is written here. - * @return - */ - LumpInfo const* lumpInfo(lumpnum_t absoluteLumpNum, int* lumpIdx = 0); - - // Convenient lookup method for when only the length property is needed from a LumpInfo. - inline size_t lumpLength(lumpnum_t absoluteLumpNum) { - if(LumpInfo const* info = lumpInfo(absoluteLumpNum)) return info->size; - return 0; - } - - // Convenient lookup method for when only the last-modified property is needed from a LumpInfo. - inline uint lumpLastModified(lumpnum_t absoluteLumpNum) { - if(LumpInfo const* info = lumpInfo(absoluteLumpNum)) return info->lastModified; - return 0; - } - - /** - * Opens the given file (will be translated) for reading. - * - * @post If @a allowDuplicate = @c false a new file ID for this will have been - * added to the list of known file identifiers if this file hasn't yet been - * opened. It is the responsibility of the caller to release this identifier when done. - * - * @param path Possibly relative or mapped path to the resource being opened. - * @param mode 't' = text mode (with real files, lumps are always binary) - * 'b' = binary - * 'f' = must be a real file in the local file system - * @param baseOffset Offset from the start of the file in bytes to begin. - * @param allowDuplicate @c false = open only if not already opened. - * - * @return Opened file reference/handle else @c NULL. - */ - DFile* openFile(char const* path, char const* mode, size_t baseOffset = 0, - bool allowDuplicate = true); - - /** - * Try to locate the specified lump for reading. - * - * @param absoluteLumpNum Logical lumpnum associated to the file being looked up. - * - * @return Handle to the opened file if found. - */ - DFile* openLump(lumpnum_t absoluteLumpNum); - - /// Clear all references to this file. - void releaseFile(AbstractFile& file); - - /// Close this file handle. - void closeFile(DFile& hndl); - - /// Completely destroy this file; close if open, clear references and any acquired identifiers. - void deleteFile(DFile& hndl); - - /** - * Parm is passed on to the callback, which is called for each file - * matching the filespec. Absolute path names are given to the callback. - * Zip directory, DD_DIREC and the real files are scanned. - * - * @param flags @see searchPathFlags - */ - int allResourcePaths(char const* searchPath, int flags, int (*callback) (char const* path, PathDirectoryNodeType type, void* parameters), void* parameters = 0); - - /** - * Finds all files. - * - * @param found Set of files that match the result. - * - * @return Number of files found. - */ - int findAll(FileList& found); - - /** - * Finds all files which meet the supplied @a predicate. - * - * @param predicate If not @c NULL, this predicate evaluator callback must - * return @c true for a given file to be included in the - * @a found FileList. - * @param parameters Passed to the predicate evaluator callback. - * @param found Set of files that match the result. - * - * @return Number of files found. - */ - int findAll(bool (*predicate)(DFile* hndl, void* parameters), void* parameters, - FileList& found); - - /** - * Print contents of the specified directory of the virtual file system. - */ - void printDirectory(ddstring_t const* path); - - /** - * Print contents of the primary lump index. - */ - void printIndex(); - - /** - * Calculate a CRC for the loaded file list. - */ - uint loadedFilesCRC(); +namespace de +{ /** - * Try to open the specified WAD archive into the auxiliary lump index. + * Internally the lump index has two parts: the Primary index (which is populated + * with lumps from loaded data files) and the Auxiliary index (used to temporarily + * open a file that is not considered part of the filesystem). * - * @return Base index for lumps in this archive. - */ - lumpnum_t openAuxiliary(char const* fileName, size_t baseOffset = 0); - - /** - * Close the auxiliary lump index if open. - */ - void closeAuxiliary(); - -private: - struct Instance; - Instance* d; - - /** - * Removes a file from any lump indexes. + * Functions that don't know the absolute/logical lumpnum of file will have to check + * both indexes (e.g., FS::lumpNumForName()). * - * @param file File to remove from the index. - */ - void deindex(AbstractFile& file); - - bool unloadFile(char const* path, bool permitRequired = false, bool quiet = false); - - FILE* findRealFile(char const* path, char const* mymode, ddstring_t** foundPath); - - /** - * @param mode 'b' = binary mode - * 't' = text mode - * 'f' = must be a real file in the local file system. - * 'x' = skip buffering (used with file-access and metadata-acquire processes). + * @ingroup fs */ - DFile* tryOpenFile2(char const* path, char const* mode, size_t baseOffset, bool allowDuplicate); - DFile* tryOpenFile(char const* path, char const* mode, size_t baseOffset, bool allowDuplicate); -}; + class FS + { + public: + typedef QList FileList; + + public: + /** + * Constructs a new file system. + */ + FS(); + + virtual ~FS(); + + /// Register the console commands, variables, etc..., of this module. + static void consoleRegister(); + + /** + * @post No more WADs will be loaded in startup mode. + */ + void endStartup(); + + /** + * Remove all file records flagged Runtime. + * @return Number of records removed. + */ + int reset(); + + /** + * (Re-)Initialize the path mappings. + */ + void initPathMap(); + + /** + * Add a new path mapping from source to destination in the vfs. + * @note Paths will be transformed into absolute paths if needed. + */ + void mapPath(char const* source, char const* destination); + + /** + * (Re-)Initialize the path => lump mappings. + * @note Should be called after WADs have been processed. + */ + void initLumpPathMap(); + + /** + * Add a new lump mapping so that @a lumpName becomes visible as @a symbolicPath + * throughout the vfs. + * @note @a symbolicPath will be transformed into an absolute path if needed. + */ + void mapPathToLump(char const* symbolicPath, char const* lumpName); + + /** + * Reset known fileId records so that the next time F_CheckFileId() is + * called on a file, it will pass. + */ + void resetFileIds(); + + /** + * Maintains a list of identifiers already seen. + * + * @return @c true if the given file can be opened, or + * @c false, if it has already been opened. + */ + bool checkFileId(char const* path); + + /** + * @return @c true if a file exists at @a path which can be opened for reading. + */ + bool accessFile(char const* path); + + /** + * @return The time when the file was last modified, as seconds since + * the Epoch else zero if the file is not found. + */ + uint lastModified(char const* fileName); + + /** + * Files with a .wad extension are archived data files with multiple 'lumps', + * other files are single lumps whose base filename will become the lump name. + * + * @param path Path to the file to be opened. Either a "real" file in the local + * file system, or a "virtual" file in the virtual file system. + * @param baseOffset Offset from the start of the file in bytes to begin. + * + * @return Newly added file instance if the operation is successful, else @c NULL. + */ + AbstractFile* addFile(char const* path, size_t baseOffset = 0); + + /// @note All files are added with baseOffset = @c 0. + int addFiles(char const* const* paths, int num); + + /** + * Attempt to remove a file from the virtual file system. + * + * @param permitRequired @c true= allow removal of resources marked as "required" + * by the currently loaded Game. + * @return @c true if the operation is successful. + */ + bool removeFile(char const* path, bool permitRequired = false); + + int removeFiles(char const* const* paths, int num, bool permitRequired = false); + + /** + * Find a lump in the Zip LumpIndex. + * + * @param path Path to search for. Relative paths are made absolute if necessary. + * @param lumpIdx If not @c NULL the translated lumpnum within the owning file object is written here. + * @return File system object representing the file which contains the found lump else @c NULL. + */ + AbstractFile* findLumpFile(char const* path, int* lumpIdx = 0); + + /// @return Number of lumps in the currently active LumpIndex. + int lumpCount(); + + bool isValidLumpNum(lumpnum_t absoluteLumpNum); + + lumpnum_t lumpNumForName(char const* name, bool silent = true); + + char const* lumpName(lumpnum_t absoluteLumpNum); + + /** + * Given a logical @a lumpnum retrieve the associated file object. + * + * @post The active LumpIndex may have changed! + * + * @param absoluteLumpNum Logical lumpnum associated to the file being looked up. + * @param lumpIdx If not @c NULL the translated lumpnum within the owning + * file object is written here. + * + * @return Found file object else @c NULL + */ + AbstractFile* lumpFile(lumpnum_t absoluteLumpNum, int* lumpIdx = 0); + + // Convenient lookup method for when only the path is needed from the source file. + inline char const* lumpFilePath(lumpnum_t absoluteLumpNum) { + if(AbstractFile* file = lumpFile(absoluteLumpNum)) return Str_Text(file->path()); + return ""; + } + + // Convenient lookup method for when only the custom property is needed from the source file. + bool lumpFileHasCustom(lumpnum_t absoluteLumpNum) { + if(AbstractFile* file = lumpFile(absoluteLumpNum)) return file->hasCustom(); + return false; + } + + /** + * Retrieve the LumpInfo metadata structure for a lump. + * + * @post The active LumpIndex may have changed! + * + * @param absoluteLumpNum Logical lumpnum associated to the file being looked up. + * @param lumpIdx If not @c NULL the translated lumpnum within the owning + * file object is written here. + * @return + */ + LumpInfo const* lumpInfo(lumpnum_t absoluteLumpNum, int* lumpIdx = 0); + + // Convenient lookup method for when only the length property is needed from a LumpInfo. + inline size_t lumpLength(lumpnum_t absoluteLumpNum) { + if(LumpInfo const* info = lumpInfo(absoluteLumpNum)) return info->size; + return 0; + } + + // Convenient lookup method for when only the last-modified property is needed from a LumpInfo. + inline uint lumpLastModified(lumpnum_t absoluteLumpNum) { + if(LumpInfo const* info = lumpInfo(absoluteLumpNum)) return info->lastModified; + return 0; + } + + /** + * Opens the given file (will be translated) for reading. + * + * @post If @a allowDuplicate = @c false a new file ID for this will have been + * added to the list of known file identifiers if this file hasn't yet been + * opened. It is the responsibility of the caller to release this identifier when done. + * + * @param path Possibly relative or mapped path to the resource being opened. + * @param mode 't' = text mode (with real files, lumps are always binary) + * 'b' = binary + * 'f' = must be a real file in the local file system + * @param baseOffset Offset from the start of the file in bytes to begin. + * @param allowDuplicate @c false = open only if not already opened. + * + * @return Opened file reference/handle else @c NULL. + */ + DFile* openFile(char const* path, char const* mode, size_t baseOffset = 0, + bool allowDuplicate = true); + + /** + * Try to locate the specified lump for reading. + * + * @param absoluteLumpNum Logical lumpnum associated to the file being looked up. + * + * @return Handle to the opened file if found. + */ + DFile* openLump(lumpnum_t absoluteLumpNum); + + /// Clear all references to this file. + void releaseFile(AbstractFile& file); + + /// Close this file handle. + void closeFile(DFile& hndl); + + /// Completely destroy this file; close if open, clear references and any acquired identifiers. + void deleteFile(DFile& hndl); + + /** + * Parm is passed on to the callback, which is called for each file + * matching the filespec. Absolute path names are given to the callback. + * Zip directory, DD_DIREC and the real files are scanned. + * + * @param flags @see searchPathFlags + */ + int allResourcePaths(char const* searchPath, int flags, int (*callback) (char const* path, PathDirectoryNodeType type, void* parameters), void* parameters = 0); + + /** + * Finds all files. + * + * @param found Set of files that match the result. + * + * @return Number of files found. + */ + int findAll(FileList& found); + + /** + * Finds all files which meet the supplied @a predicate. + * + * @param predicate If not @c NULL, this predicate evaluator callback must + * return @c true for a given file to be included in the + * @a found FileList. + * @param parameters Passed to the predicate evaluator callback. + * @param found Set of files that match the result. + * + * @return Number of files found. + */ + int findAll(bool (*predicate)(DFile* hndl, void* parameters), void* parameters, + FileList& found); + + /** + * Print contents of the specified directory of the virtual file system. + */ + void printDirectory(ddstring_t const* path); + + /** + * Print contents of the primary lump index. + */ + void printIndex(); + + /** + * Calculate a CRC for the loaded file list. + */ + uint loadedFilesCRC(); + + /** + * Try to open the specified WAD archive into the auxiliary lump index. + * + * @return Base index for lumps in this archive. + */ + lumpnum_t openAuxiliary(char const* fileName, size_t baseOffset = 0); + + /** + * Close the auxiliary lump index if open. + */ + void closeAuxiliary(); + + private: + struct Instance; + Instance* d; + + /** + * Removes a file from any lump indexes. + * + * @param file File to remove from the index. + */ + void deindex(AbstractFile& file); + + bool unloadFile(char const* path, bool permitRequired = false, bool quiet = false); + + FILE* findRealFile(char const* path, char const* mymode, ddstring_t** foundPath); + + /** + * @param mode 'b' = binary mode + * 't' = text mode + * 'f' = must be a real file in the local file system. + * 'x' = skip buffering (used with file-access and metadata-acquire processes). + */ + DFile* tryOpenFile2(char const* path, char const* mode, size_t baseOffset, bool allowDuplicate); + DFile* tryOpenFile(char const* path, char const* mode, size_t baseOffset, bool allowDuplicate); + }; } // namespace de diff --git a/doomsday/engine/portable/src/abstractfile.cpp b/doomsday/engine/portable/src/abstractfile.cpp index e6917befd0..f8e841b8c0 100644 --- a/doomsday/engine/portable/src/abstractfile.cpp +++ b/doomsday/engine/portable/src/abstractfile.cpp @@ -31,7 +31,7 @@ namespace de { AbstractFile::AbstractFile(filetype_t _type, char const* _path, DFile& file, LumpInfo const& _info) - : file(&file), type_(_type) + : file(&file), type_(_type), flags(DefaultFlags) { // Used to favor newer files when duplicates are pruned. /// @todo Does not belong at this level. Load order should be determined @@ -40,8 +40,6 @@ AbstractFile::AbstractFile(filetype_t _type, char const* _path, DFile& file, Lum DENG2_ASSERT(VALID_FILETYPE(_type)); order = fileCounter++; - flags.startup = false; - flags.custom = true; Str_Init(&path_); Str_Set(&path_, _path); info_ = _info; } @@ -74,9 +72,9 @@ AbstractFile& AbstractFile::container() const return *info_.container; } -de::DFile* de::AbstractFile::handle() +de::DFile& de::AbstractFile::handle() { - return file; + return *file; } ddstring_t const* AbstractFile::path() const @@ -91,23 +89,25 @@ uint AbstractFile::loadOrderIndex() const bool AbstractFile::hasStartup() const { - return !!flags.startup; + return flags.testFlag(Startup); } AbstractFile& AbstractFile::setStartup(bool yes) { - flags.startup = yes; + if(yes) flags |= Startup; + else flags &= ~Startup; return *this; } bool AbstractFile::hasCustom() const { - return !!flags.custom; + return flags.testFlag(Custom); } AbstractFile& AbstractFile::setCustom(bool yes) { - flags.custom = yes; + if(yes) flags |= Custom; + else flags &= ~Custom; return *this; } diff --git a/doomsday/engine/portable/src/dfile.cpp b/doomsday/engine/portable/src/dfile.cpp index 806b77d6b2..c8c435fd9b 100644 --- a/doomsday/engine/portable/src/dfile.cpp +++ b/doomsday/engine/portable/src/dfile.cpp @@ -270,7 +270,7 @@ size_t DFile::baseOffset() const { if(d->flags.reference) { - return d->file->handle()->baseOffset(); + return d->file->handle().baseOffset(); } return d->baseOffset; } @@ -280,7 +280,7 @@ size_t DFile::length() errorIfNotValid(*this, "DFile::Length"); if(d->flags.reference) { - return d->file->handle()->length(); + return d->file->handle().length(); } else { @@ -296,7 +296,7 @@ size_t DFile::read(uint8_t* buffer, size_t count) errorIfNotValid(*this, "DFile::read"); if(d->flags.reference) { - return d->file->handle()->read(buffer, count); + return d->file->handle().read(buffer, count); } else { @@ -330,7 +330,7 @@ bool DFile::atEnd() errorIfNotValid(*this, "DFile::atEnd"); if(d->flags.reference) { - return d->file->handle()->atEnd(); + return d->file->handle().atEnd(); } return (d->flags.eof != 0); } @@ -349,7 +349,7 @@ size_t DFile::tell() errorIfNotValid(*this, "DFile::tell"); if(d->flags.reference) { - return d->file->handle()->tell(); + return d->file->handle().tell(); } else { @@ -363,7 +363,7 @@ size_t DFile::seek(size_t offset, SeekMethod whence) { if(d->flags.reference) { - return d->file->handle()->seek(offset, whence); + return d->file->handle().seek(offset, whence); } else { @@ -488,15 +488,3 @@ struct abstractfile_s* DFile_File_const(struct dfile_s const* hndl) SELF_CONST(hndl); return reinterpret_cast(&self->file()); } - -struct filelist_s* DFile_List(struct dfile_s* hndl) -{ - SELF(hndl); - return self->list(); -} - -struct dfile_s* DFile_SetList(struct dfile_s* hndl, struct filelist_s* list) -{ - SELF(hndl); - return reinterpret_cast(&self->setList(list)); -} diff --git a/doomsday/engine/portable/src/fs_main.cpp b/doomsday/engine/portable/src/fs_main.cpp index 0ee0f395de..faff4c4dbd 100644 --- a/doomsday/engine/portable/src/fs_main.cpp +++ b/doomsday/engine/portable/src/fs_main.cpp @@ -274,7 +274,7 @@ void FS::consoleRegister() * @note Performance is O(n). * @return @c iterator pointing to list->end() if not found. */ -static de::FileList::iterator findListFileByPath(de::FileList& list, char const* path_) +static FS::FileList::iterator findListFileByPath(FS::FileList& list, char const* path_) { if(list.empty()) return list.end(); if(!path_ || !path_[0]) return list.end(); @@ -284,7 +284,7 @@ static de::FileList::iterator findListFileByPath(de::FileList& list, char const* F_FixSlashes(path, path); // Perform the search. - de::FileList::iterator i; + FS::FileList::iterator i; for(i = list.begin(); i != list.end(); ++i) { de::AbstractFile& file = (*i)->file(); @@ -372,7 +372,7 @@ static void printFileIds(FileIds const& fileIds) #endif #if _DEBUG -static void printFileList(de::FileList& list) +static void printFileList(FS::FileList& list) { for(int i = 0; i < list.size(); ++i) { @@ -707,10 +707,10 @@ void FS::deleteFile(de::DFile& hndl) } /// @return @c NULL= Not found. -static WadFile* findFirstWadFile(de::FileList& list, bool custom) +static WadFile* findFirstWadFile(FS::FileList& list, bool custom) { if(list.empty()) return 0; - DENG2_FOR_EACH(i, list, de::FileList::iterator) + DENG2_FOR_EACH(i, list, FS::FileList::iterator) { de::AbstractFile& file = (*i)->file(); if(custom != file.hasCustom()) continue; @@ -732,10 +732,10 @@ uint FS::loadedFilesCRC() return iwad->calculateCRC(); } -int FS::findAll(de::FileList& found) +int FS::findAll(FS::FileList& found) { int numFound = 0; - DENG2_FOR_EACH(i, d->loadedFiles, de::FileList::const_iterator) + DENG2_FOR_EACH(i, d->loadedFiles, FS::FileList::const_iterator) { found.push_back(*i); numFound += 1; @@ -744,10 +744,10 @@ int FS::findAll(de::FileList& found) } int FS::findAll(bool (*predicate)(de::DFile* hndl, void* parameters), void* parameters, - de::FileList& found) + FS::FileList& found) { int numFound = 0; - DENG2_FOR_EACH(i, d->loadedFiles, de::FileList::const_iterator) + DENG2_FOR_EACH(i, d->loadedFiles, FS::FileList::const_iterator) { // Interested in this file? if(predicate && !predicate(*i, parameters)) continue; // Nope. @@ -1732,11 +1732,11 @@ D_CMD(ListFiles) size_t totalFiles = 0, totalPackages = 0; if(fileSystem) { - de::FileList foundFiles; + FS::FileList foundFiles; int fileCount = App_FileSystem()->findAll(foundFiles); if(!fileCount) return true; - DENG2_FOR_EACH(i, foundFiles, de::FileList::const_iterator) + DENG2_FOR_EACH(i, foundFiles, FS::FileList::const_iterator) { de::AbstractFile& file = (*i)->file(); uint crc; @@ -2051,7 +2051,7 @@ AutoStr* F_ComposeLumpPath(struct abstractfile_s* file, int lumpIdx) * should ensure to release it with Str_Delete() when no longer needed. * Always returns a valid (but perhaps zero-length) string object. */ -static ddstring_t* composeFilePathString(de::FileList& files, int flags = DEFAULT_PATHTOSTRINGFLAGS, +static ddstring_t* composeFilePathString(FS::FileList& files, int flags = DEFAULT_PATHTOSTRINGFLAGS, char const* delimiter = " ") { int maxLength, delimiterLength = (delimiter? (int)strlen(delimiter) : 0); @@ -2063,7 +2063,7 @@ static ddstring_t* composeFilePathString(de::FileList& files, int flags = DEFAUL // Determine the maximum number of characters we'll need. maxLength = 0; - DENG2_FOR_EACH(i, files, de::FileList::const_iterator) + DENG2_FOR_EACH(i, files, FS::FileList::const_iterator) { ddstring_t const* path = (*i)->file().path(); @@ -2117,7 +2117,7 @@ static ddstring_t* composeFilePathString(de::FileList& files, int flags = DEFAUL str = Str_New(); Str_Reserve(str, maxLength); n = 0; - DENG2_FOR_EACH(i, files, de::FileList::const_iterator) + DENG2_FOR_EACH(i, files, FS::FileList::const_iterator) { ddstring_t const* path = (*i)->file().path(); @@ -2208,7 +2208,7 @@ void F_ComposeFileList(filetype_t type, boolean markedCustom, char* outBuf, size memset(outBuf, 0, outBufSize); findfilespredicate_params_t p = { type, CPP_BOOL(markedCustom) }; - de::FileList foundFiles; + FS::FileList foundFiles; if(!App_FileSystem()->findAll(findFilesPredicate, (void*)&p, foundFiles)) return; ddstring_t* str = composeFilePathString(foundFiles, PTSF_TRANSFORM_EXCLUDE_DIR, delimiter); diff --git a/doomsday/engine/portable/src/fs_util.cpp b/doomsday/engine/portable/src/fs_util.cpp index 6e6037aa39..5bd66d330b 100644 --- a/doomsday/engine/portable/src/fs_util.cpp +++ b/doomsday/engine/portable/src/fs_util.cpp @@ -42,6 +42,8 @@ #include "de_filesys.h" #include "de_misc.h" +#include + using namespace de; void F_FileDir(ddstring_t* dst, const ddstring_t* src)