Skip to content

Commit

Permalink
Relative paths on the command line
Browse files Browse the repository at this point in the history
The arguments of -file, -iwad, -def, -defs, -basedir, -userdir and resource
directory options are now interpreted to be relative to the command line's
initial directory.
  • Loading branch information
skyjake committed May 23, 2012
1 parent f9bb5b1 commit 7633ae3
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions doomsday/engine/portable/src/dd_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1564,7 +1564,7 @@ boolean DD_Init(void)

while(++p != CommandLine_Count() && !CommandLine_IsOption(p))
{
const char* filePath = CommandLine_At(p);
const char* filePath = CommandLine_PathAt(p);
directory_t* dir;
Uri* searchPath;

Expand Down Expand Up @@ -1615,7 +1615,7 @@ boolean DD_Init(void)

while(++p != CommandLine_Count() && !CommandLine_IsOption(p))
{
addToPathList(&gameResourceFileList, &numGameResourceFileList, CommandLine_At(p));
addToPathList(&gameResourceFileList, &numGameResourceFileList, CommandLine_PathAt(p));
}

p--;/* For ArgIsOption(p) necessary, for p==Argc() harmless */
Expand Down
5 changes: 3 additions & 2 deletions doomsday/engine/portable/src/def_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -869,11 +869,12 @@ static void readAllDefinitions(void)
for(p = 0; p < CommandLine_Count(); ++p)
{
const char* arg = CommandLine_At(p);
if(!CommandLine_IsMatchingAlias("-def", arg) && !CommandLine_IsMatchingAlias("-defs", arg)) continue;
if(!CommandLine_IsMatchingAlias("-def", arg) &&
!CommandLine_IsMatchingAlias("-defs", arg)) continue;

while(++p != CommandLine_Count() && !CommandLine_IsOption(p))
{
const char* searchPath = CommandLine_At(p);
const char* searchPath = CommandLine_PathAt(p);

Con_Message(" Processing '%s'...\n", F_PrettyPath(searchPath));

Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/portable/src/sys_reslocator.c
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ void F_CreateNamespacesForFileResourcePaths(void)

if(def->optOverridePath && CommandLine_CheckWith(def->optOverridePath, 1))
{
const char* path = CommandLine_Next();
const char* path = CommandLine_NextAsPath();
ddstring_t path2;

// Override paths are added in reverse order.
Expand All @@ -810,7 +810,7 @@ void F_CreateNamespacesForFileResourcePaths(void)

if(def->optFallbackPath && CommandLine_CheckWith(def->optFallbackPath, 1))
{
Uri_SetUri3(uri, CommandLine_Next(), RC_NULL);
Uri_SetUri3(uri, CommandLine_NextAsPath(), RC_NULL);
ResourceNamespace_AddSearchPath(rnamespace, def->searchPathFlags, uri, SPG_FALLBACK);
}
}}
Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/unix/src/dd_uinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ static void determineGlobalPaths(application_t* app)
filename_t runtimePath;
directory_t* temp;

strncpy(runtimePath, CommandLine_Next(), FILENAME_T_MAXLEN);
strncpy(runtimePath, CommandLine_NextAsPath(), FILENAME_T_MAXLEN);
Dir_CleanPath(runtimePath, FILENAME_T_MAXLEN);
// Ensure the path is closed with a directory separator.
F_AppendMissingSlashCString(runtimePath, FILENAME_T_MAXLEN);
Expand Down Expand Up @@ -303,7 +303,7 @@ static void determineGlobalPaths(application_t* app)
*/
if(CommandLine_CheckWith("-basedir", 1))
{
strncpy(ddBasePath, CommandLine_Next(), FILENAME_T_MAXLEN);
strncpy(ddBasePath, CommandLine_NextAsPath(), FILENAME_T_MAXLEN);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/win32/src/dd_winit.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ static void determineGlobalPaths(application_t* app)
filename_t runtimePath;
directory_t* temp;

strncpy(runtimePath, CommandLine_Next(), FILENAME_T_MAXLEN);
strncpy(runtimePath, CommandLine_NextAsPath(), FILENAME_T_MAXLEN);
Dir_CleanPath(runtimePath, FILENAME_T_MAXLEN);
// Ensure the path is closed with a directory separator.
F_AppendMissingSlashCString(runtimePath, FILENAME_T_MAXLEN);
Expand Down

0 comments on commit 7633ae3

Please sign in to comment.