Skip to content

Commit

Permalink
Refactor|FileSys: FS1 API now uses de::String, native paths pushed to…
Browse files Browse the repository at this point in the history
… the periphery

The FS1 API now uses de::String throughout to represent paths within
the virtual file system.

Native paths (those which may include symbolic directives) have been
pushed out to the periphery of the FS1 API (only the C wrapper deals
with them now).

Internally all virtual paths are now either absolute or relative,
with no embedded directives or other symbolics.
  • Loading branch information
danij-deng committed Nov 9, 2012
1 parent a6512d3 commit f8b95f7
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 175 deletions.
28 changes: 13 additions & 15 deletions doomsday/engine/portable/include/fs_main.h
Expand Up @@ -112,7 +112,7 @@ namespace de
* 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);
void mapPath(String source, String destination);

/**
* Clears all virtual path mappings.
Expand All @@ -122,11 +122,9 @@ namespace de
FS1& clearPathMappings();

/**
* 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.
* Add a new lump mapping so that @a lumpName becomes visible at @a destination.
*/
void mapPathToLump(char const* symbolicPath, char const* lumpName);
void mapPathToLump(String lumpName, String destination);

/**
* Clears all path => lump mappings.
Expand Down Expand Up @@ -171,7 +169,7 @@ namespace de
*/
FS1& deindex(File1& file);

lumpnum_t lumpNumForName(char const* name, bool silent = true);
lumpnum_t lumpNumForName(String name, bool silent = true);

/**
* Provides access to the currently active Wad lump name index. This can
Expand Down Expand Up @@ -296,12 +294,12 @@ namespace de
*
* @return Number of paths found.
*/
int findAllPaths(char const* searchPattern, int flags, PathList& found);
int findAllPaths(String searchPattern, int flags, PathList& found);

/**
* Print contents of the specified directory of the virtual file system.
*/
void printDirectory(ddstring_t const* path);
void printDirectory(String path);

/**
* Calculate a CRC for the loaded file list.
Expand Down Expand Up @@ -367,9 +365,9 @@ void F_EndStartup(void);

void F_UnloadAllNonStartupFiles(int* numUnloaded);

void F_AddVirtualDirectoryMapping(char const* source, char const* destination);
void F_AddVirtualDirectoryMapping(char const* nativeSourcePath, char const* nativeDestinationPath);

void F_AddLumpDirectoryMapping(char const* lumpName, char const* symbolicPath);
void F_AddLumpDirectoryMapping(char const* lumpName, char const* nativeDestinationPath);

void F_ResetFileIds(void);

Expand All @@ -383,9 +381,9 @@ void F_Index(struct file1_s* file);

void F_Deindex(struct file1_s* file);

FileHandle* F_Open3(char const* path, char const* mode, size_t baseOffset, boolean allowDuplicate);
FileHandle* F_Open2(char const* path, char const* mode, size_t baseOffset/*, allowDuplicate = true */);
FileHandle* F_Open(char const* path, char const* mode/*, baseOffset = 0 */);
FileHandle* F_Open3(char const* nativePath, char const* mode, size_t baseOffset, boolean allowDuplicate);
FileHandle* F_Open2(char const* nativePath, char const* mode, size_t baseOffset/*, allowDuplicate = true */);
FileHandle* F_Open(char const* nativePath, char const* mode/*, baseOffset = 0 */);

FileHandle* F_OpenLump(lumpnum_t absoluteLumpNum);

Expand Down Expand Up @@ -431,8 +429,8 @@ void F_ComposePWADFileList(char* outBuf, size_t outBufSize, const char* delimite

uint F_CRCNumber(void);

lumpnum_t F_OpenAuxiliary2(char const* fileName, size_t baseOffset);
lumpnum_t F_OpenAuxiliary(char const* fileName/*, baseOffset = 0 */);
lumpnum_t F_OpenAuxiliary2(char const* nativePath, size_t baseOffset);
lumpnum_t F_OpenAuxiliary(char const* nativePath/*, baseOffset = 0 */);

void F_CloseAuxiliary(void);

Expand Down
12 changes: 8 additions & 4 deletions doomsday/engine/portable/src/dd_main.cpp
Expand Up @@ -29,6 +29,9 @@
# include <objbase.h>
#endif

#include <QDir>
#include <QStringList>

#include <de/NativePath>

#include "de_platform.h"
Expand Down Expand Up @@ -58,8 +61,6 @@
#include "updater.h"
#include "wad.h"

#include <QStringList>

using namespace de;

typedef struct ddvalue_s {
Expand Down Expand Up @@ -532,7 +533,9 @@ static void initPathMappings()

if(i < argC - 1 && !CommandLine_IsOption(i + 1) && !CommandLine_IsOption(i + 2))
{
App_FileSystem()->mapPath(CommandLine_PathAt(i + 1), CommandLine_At(i + 2));
String source = QDir::fromNativeSeparators(NativePath(CommandLine_PathAt(i + 1)).expand());
String destination = QDir::fromNativeSeparators(NativePath(CommandLine_PathAt(i + 2)).expand());
App_FileSystem()->mapPath(source, destination);
i += 2;
}
}
Expand Down Expand Up @@ -607,7 +610,8 @@ static bool parsePathLumpMappings(char const* buffer)
}
else
{
App_FileSystem()->mapPathToLump(Str_Text(&path), lumpName);
String destination = QDir::fromNativeSeparators(NativePath(Str_Text(&path)).expand());
App_FileSystem()->mapPathToLump(lumpName, destination);
}
} while(*ch);

Expand Down
5 changes: 2 additions & 3 deletions doomsday/engine/portable/src/def_main.cpp
Expand Up @@ -868,8 +868,8 @@ static void readAllDefinitions(void)
// Next up are definition files in the Games' /auto directory.
if(!CommandLine_Exists("-noauto") && DD_GameLoaded())
{
Uri* pattern = Uri_NewWithPath2("$(App.DefsPath)/$(GamePlugin.Name)/auto/*.ded", RC_NULL);
if(ddstring_t const* resolvedPath = Uri_ResolvedConst(pattern))
de::Uri pattern = de::Uri("$(App.DefsPath)/$(GamePlugin.Name)/auto/*.ded", RC_NULL);
if(ddstring_t const* resolvedPath = pattern.resolvedConst())
{
de::FS1::PathList found;
if(App_FileSystem()->findAllPaths(Str_Text(resolvedPath), 0, found))
Expand All @@ -884,7 +884,6 @@ static void readAllDefinitions(void)
}
}
}
Uri_Delete(pattern);
}

// Any definition files on the command line?
Expand Down

0 comments on commit f8b95f7

Please sign in to comment.