Skip to content

Commit

Permalink
Win32: Fixed -userdir paths not ending in a directory separator
Browse files Browse the repository at this point in the history
Ensure -userdir path is always closed.
  • Loading branch information
danij-deng committed Jan 2, 2012
1 parent 6b3d86e commit cc9d0fe
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
11 changes: 10 additions & 1 deletion doomsday/engine/unix/src/dd_uinit.c
Expand Up @@ -253,7 +253,16 @@ static void determineGlobalPaths(application_t* app)
// The -userdir option sets the working directory.
if(ArgCheckWith("-userdir", 1))
{
directory_t* temp = Dir_New(ArgNext());
filename_t runtimePath;
directory_t* temp;

strncpy(runtimePath, ArgNext(), FILENAME_T_MAXLEN);
Dir_CleanPath(runtimePath, FILENAME_T_MAXLEN);
// Ensure the path is closed with a directory separator.
if(runtimePath[strlen(runtimePath)-1] != '/')
strncat(runtimePath, "/", FILENAME_T_MAXLEN);

temp = Dir_New(runtimePath);
app->usingUserDir = Dir_SetCurrent(Dir_Path(temp));
if(app->usingUserDir)
{
Expand Down
11 changes: 10 additions & 1 deletion doomsday/engine/win32/src/dd_winit.c
Expand Up @@ -364,7 +364,16 @@ static void determineGlobalPaths(application_t* app)
// The -userdir option sets the working directory.
if(ArgCheckWith("-userdir", 1))
{
directory_t* temp = Dir_ConstructFromPathDir(ArgNext());
filename_t runtimePath;
directory_t* temp;

strncpy(runtimePath, ArgNext(), FILENAME_T_MAXLEN);
Dir_CleanPath(runtimePath, FILENAME_T_MAXLEN);
// Ensure the path is closed with a directory separator.
if(runtimePath[strlen(runtimePath)-1] != '/')
strncat(runtimePath, "/", FILENAME_T_MAXLEN);

temp = Dir_New(runtimePath);
app->usingUserDir = Dir_SetCurrent(Dir_Path(temp));
if(app->usingUserDir)
{
Expand Down

0 comments on commit cc9d0fe

Please sign in to comment.