Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Minor get_current_dir() fixes.
  • Loading branch information
icculus committed May 18, 2005
1 parent 9ce3fcf commit e2e19df
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 15 additions & 1 deletion platform_unix.c
Expand Up @@ -524,7 +524,21 @@ int spawn_xdelta(const char *cmdline)

char *get_current_dir(char *buf, size_t bufsize)
{
return(getcwd(buf, bufsize));
size_t buflen = 0;
if (getcwd(buf, bufsize) == NULL)
return(NULL);

buflen = strlen(buf) + 1;
if (buflen <= bufsize)
{
*buf = '\0';
return(NULL);
} /* if */

if (buf[buflen - 2] != '/')
strcat(buf, "/");

return(buf);
} /* get_current_dir */


Expand Down
2 changes: 1 addition & 1 deletion platform_win32.c
Expand Up @@ -128,7 +128,7 @@ char *get_current_dir(char *buf, size_t bufsize);
if (buflen <= bufsize)
{
*buf = '\0';
return NULL;
return(NULL);
} /* if */

if (buf[buflen - 2] != '\\')
Expand Down

0 comments on commit e2e19df

Please sign in to comment.