Skip to content

Commit

Permalink
Cleanup|Refactor: Removed obsolete sys_direc.cpp/h from libdoomsday
Browse files Browse the repository at this point in the history
Native directory operations are nowadays done by the NativePath class.

IssueID #1829
  • Loading branch information
skyjake committed Jul 20, 2016
1 parent 1c99e9e commit bf25933
Show file tree
Hide file tree
Showing 15 changed files with 70 additions and 634 deletions.
36 changes: 2 additions & 34 deletions doomsday/apps/client/src/dd_main.cpp
Expand Up @@ -62,7 +62,6 @@
#include <doomsday/console/var.h>
#include <doomsday/filesys/fs_main.h>
#include <doomsday/filesys/fs_util.h>
#include <doomsday/filesys/sys_direc.h>
#include <doomsday/filesys/virtualmappings.h>
#include <doomsday/resource/databundle.h>
#include <doomsday/resource/manifest.h>
Expand Down Expand Up @@ -319,12 +318,12 @@ static void createPackagesScheme()

#ifdef UNIX
// There may be an iwaddir specified in a system-level config file.
filename_t fn;
if (UnixInfo_GetConfigValue("paths", "iwaddir", fn, FILENAME_T_MAXLEN))
if (char *fn = UnixInfo_GetConfigValue("paths", "iwaddir"))
{
NativePath path = de::App::commandLine().startupPath() / fn;
scheme.addSearchPath(SearchPath(de::Uri::fromNativeDirPath(path), SearchPath::NoDescend));
LOG_RES_NOTE("Using paths.iwaddir: %s") << path.pretty();
free(fn);
}
#endif

Expand Down Expand Up @@ -996,37 +995,6 @@ static void initialize()
BusyMode_RunNewTaskWithName(BUSYF_STARTUP | BUSYF_PROGRESS_BAR | (verbose? BUSYF_CONSOLE_OUTPUT : 0),
DD_DummyWorker, 0, "Buffering...");

#if 0
// Add resource paths specified using -iwad on the command line.
FS1::Scheme &scheme = App_FileSystem().scheme(App_ResourceClass("RC_PACKAGE").defaultScheme());
for (dint p = 0; p < CommandLine_Count(); ++p)
{
if (!CommandLine_IsMatchingAlias("-iwad", CommandLine_At(p)))
{
continue;
}

while (++p != CommandLine_Count() && !CommandLine_IsOption(p))
{
/// @todo Do not add these as search paths, publish them directly to
/// the "Packages" scheme.

// CommandLine_PathAt() always returns an absolute path.
directory_t *dir = Dir_FromText(CommandLine_PathAt(p));
de::Uri uri = de::Uri::fromNativeDirPath(Dir_Path(dir), RC_PACKAGE);

LOG_RES_NOTE("User-supplied IWAD path: \"%s\"") << Dir_Path(dir);

scheme.addSearchPath(SearchPath(uri, SearchPath::NoDescend));

Dir_Delete(dir);
}

p--;/* For ArgIsOption(p) necessary, for p==Argc() harmless */
}

App_ResourceSystem().updateOverrideIWADPathFromConfig();
#endif
//
// Try to locate all required data files for all registered games.
//
Expand Down
30 changes: 17 additions & 13 deletions doomsday/apps/client/src/def_main.cpp
Expand Up @@ -44,7 +44,6 @@
#include <doomsday/defs/state.h>
#include <doomsday/filesys/fs_main.h>
#include <doomsday/filesys/fs_util.h>
#include <doomsday/filesys/sys_direc.h>
#include <doomsday/resource/manifest.h>
#include <doomsday/res/Bundles>
#include <doomsday/res/Textures>
Expand Down Expand Up @@ -425,6 +424,7 @@ static void readDefinitionFile(String path)
Def_ReadProcessDED(&defs, path);
}

#if 0
/**
* Attempt to prepend the current work path. If @a src is already absolute do nothing.
*
Expand All @@ -437,10 +437,13 @@ static void prependWorkPath(ddstring_t *dst, ddstring_t const *src)

if (!F_IsAbsolute(src))
{
char *curPath = Dir_CurrentPath();
Str_Prepend(dst, curPath);
Dir_CleanPathStr(dst);
M_Free(curPath);
NativePath prepended = NativePath::workPath() / Str_Text(src);

//char *curPath = Dir_CurrentPath();
//Str_Prepend(dst, curPath.);
//Dir_CleanPathStr(dst);
//M_Free(curPath);

return;
}

Expand All @@ -450,6 +453,7 @@ static void prependWorkPath(ddstring_t *dst, ddstring_t const *src)
Str_Set(dst, Str_Text(src));
}
}
#endif

/**
* Returns a URN list (in load order) for all lumps whose name matches the pattern "MAPINFO.lmp".
Expand Down Expand Up @@ -619,7 +623,6 @@ static void readAllDefinitions()
}

// Next are any definition files specified on the command line.
AutoStr *buf = AutoStr_NewStd();
for (dint p = 0; p < CommandLine_Count(); ++p)
{
char const *arg = CommandLine_At(p);
Expand All @@ -628,16 +631,17 @@ static void readAllDefinitions()

while (++p != CommandLine_Count() && !CommandLine_IsOption(p))
{
char const *searchPath = CommandLine_PathAt(p);
// CommandLine cleans the path, expands symbols, and makes it absolute.
NativePath searchPath(CommandLine_PathAt(p));

Str_Clear(buf); Str_Set(buf, searchPath);
F_FixSlashes(buf, buf);
F_ExpandBasePath(buf, buf);
//Str_Clear(buf); Str_Set(buf, searchPath);
//F_FixSlashes(buf, buf);
//F_ExpandBasePath(buf, buf);
// We must have an absolute path. If we still do not have one then
// prepend the current working directory if necessary.
prependWorkPath(buf, buf);
//prependWorkPath(buf, buf);

readDefinitionFile(String(Str_Text(buf)));
readDefinitionFile(searchPath.withSeparators('/'));
}
p--; /* For ArgIsOption(p) necessary, for p==Argc() harmless */
}
Expand Down Expand Up @@ -1072,7 +1076,7 @@ static void configureMaterial(world::Material &mat, Record const &definition)
{
res::TextureManifest *maskTexture = &resSys().textures().textureScheme("Masks")
.findByResourceUri(*shineDef->stage.maskTexture);

slayer->addStage(world::ShineTextureMaterialLayer::AnimationStage
(texture.composeUri(), stage.tics, stage.variance,
maskTexture->composeUri(), shineDef->stage.blendMode,
Expand Down
3 changes: 1 addition & 2 deletions doomsday/apps/client/src/network/net_demo.cpp
Expand Up @@ -25,7 +25,6 @@
#include <doomsday/doomsdayapp.h>
#include <doomsday/console/cmd.h>
#include <doomsday/filesys/fs_util.h>
#include <doomsday/filesys/sys_direc.h>

#include "client/cl_player.h"

Expand Down Expand Up @@ -59,7 +58,7 @@ struct demopacket_header_t

extern dfloat netConnectTime;

filename_t demoPath = "/home/demo/";
static char const *demoPath = "/home/demo/";

LZFILE *playdemo;
dint playback;
Expand Down
1 change: 0 additions & 1 deletion doomsday/apps/client/src/unix/dd_uinit.cpp
Expand Up @@ -26,7 +26,6 @@

#include <doomsday/doomsdayapp.h>
#include <doomsday/filesys/fs_util.h>
#include <doomsday/filesys/sys_direc.h>
#include <doomsday/library.h>
#include <de/c_wrapper.h>
#include <de/App>
Expand Down
10 changes: 10 additions & 0 deletions doomsday/apps/libdoomsday/include/doomsday/filesys/fs_main.h
Expand Up @@ -39,6 +39,16 @@
# include "fs_windows.h"
#endif

#ifdef WIN32
# define DENG_DIR_SEP_CHAR '\\'
# define DENG_DIR_SEP_STR "\\"
# define DENG_DIR_WRONG_SEP_CHAR '/'
#else
# define DENG_DIR_SEP_CHAR '/'
# define DENG_DIR_SEP_STR "/"
# define DENG_DIR_WRONG_SEP_CHAR '\\'
#endif

#ifdef __cplusplus

#include <QList>
Expand Down
116 changes: 0 additions & 116 deletions doomsday/apps/libdoomsday/include/doomsday/filesys/sys_direc.h

This file was deleted.

1 change: 0 additions & 1 deletion doomsday/apps/libdoomsday/src/defs/dedparser.cpp
Expand Up @@ -65,7 +65,6 @@
#include "doomsday/defs/sky.h"
#include "doomsday/filesys/fs_main.h"
#include "doomsday/filesys/fs_util.h"
#include "doomsday/filesys/sys_direc.h"
#include "doomsday/uri.h"
#include "doomsday/world/xgclass.h"

Expand Down
34 changes: 8 additions & 26 deletions doomsday/apps/libdoomsday/src/doomsdayapp.cpp
Expand Up @@ -20,7 +20,6 @@
#include "doomsday/games.h"
#include "doomsday/gameprofiles.h"
#include "doomsday/console/exec.h"
#include "doomsday/filesys/sys_direc.h"
#include "doomsday/filesys/fs_util.h"
#include "doomsday/resource/resources.h"
#include "doomsday/resource/bundles.h"
Expand Down Expand Up @@ -48,6 +47,7 @@
#include <de/c_wrapper.h>
#include <de/strutil.h>
#include <de/memoryzone.h>
#include <de/memory.h>

#include <QDir>
#include <QSettings>
Expand Down Expand Up @@ -241,10 +241,10 @@ DENG2_PIMPL(DoomsdayApp)

#ifdef UNIX
// There may be an iwaddir specified in a system-level config file.
filename_t fn;
if (UnixInfo_GetConfigValue("paths", "iwaddir", fn, FILENAME_T_MAXLEN))
if (char *fn = UnixInfo_GetConfigValue("paths", "iwaddir"))
{
attachWadFeed("UnixInfo " _E(i) "paths.iwaddir" _E(.), startupPath / fn);
free(fn);
}
#endif

Expand Down Expand Up @@ -279,11 +279,11 @@ DENG2_PIMPL(DoomsdayApp)

#ifdef UNIX
// There may be an iwaddir specified in a system-level config file.
filename_t fn;
if (UnixInfo_GetConfigValue("paths", "packsdir", fn, FILENAME_T_MAXLEN))
if (char *fn = UnixInfo_GetConfigValue("paths", "packsdir"))
{
attachPacksFeed("UnixInfo " _E(i) "paths.packsdir" _E(.),
cmdLine.startupPath() / fn);
free(fn);
}
#endif

Expand Down Expand Up @@ -501,30 +501,12 @@ std::string const &DoomsdayApp::doomsdayBasePath() const

void DoomsdayApp::setDoomsdayBasePath(NativePath const &path)
{
/// @todo Unfortunately the legacy Dir/fs_util assumes fixed-size strings, so we
/// can't take advantage of std::string. -jk
filename_t temp;
strncpy(temp, path.toUtf8(), FILENAME_T_MAXLEN);
NativePath cleaned = App::commandLine().startupPath() / path; // In case it's relative.
cleaned.addTerminatingSeparator();

Dir_CleanPath(temp, FILENAME_T_MAXLEN);
Dir_MakeAbsolutePath(temp, FILENAME_T_MAXLEN);

// Ensure it ends with a directory separator.
F_AppendMissingSlashCString(temp, FILENAME_T_MAXLEN);

d->ddBasePath = temp;
}

/*std::string const &DoomsdayApp::doomsdayRuntimePath() const
{
return d->ddRuntimePath;
d->ddBasePath = cleaned.toString().toStdString();
}

void DoomsdayApp::setDoomsdayRuntimePath(NativePath const &path)
{
d->ddRuntimePath = path.toUtf8().constData();
}*/

#ifdef WIN32
void *DoomsdayApp::moduleHandle() const
{
Expand Down
1 change: 0 additions & 1 deletion doomsday/apps/libdoomsday/src/filesys/fs_util.cpp
Expand Up @@ -43,7 +43,6 @@
#include "doomsday/DoomsdayApp"
#include "doomsday/filesys/fs_main.h"
#include "doomsday/filesys/fs_util.h"
#include "doomsday/filesys/sys_direc.h"
#include "doomsday/filesys/lumpindex.h"

#include <de/Log>
Expand Down

0 comments on commit bf25933

Please sign in to comment.