Skip to content
Permalink
Browse files
Minor brainfart fix in verifySecurity() and optimized mkdir().
  • Loading branch information
icculus committed Mar 19, 2003
1 parent 8bdc0ea commit 3744f5406413a7ee93f762f67a110af4de9b9b54
Showing with 8 additions and 6 deletions.
  1. +8 −6 physfs.c
@@ -1232,14 +1232,14 @@ int __PHYSFS_verifySecurity(DirHandle *h, const char *fname, int allowMissing)
} /* if */

/* break out early if path element is missing. */
if ((!retval) && (!allowMissing))
if (!retval)
{
/*
* We need to clear it if it's the last element of the path,
* since this might be a non-existant file we're opening
* for writing...
*/
if (end == NULL)
if ((end == NULL) || (allowMissing))
retval = 1;
break;
} /* if */
@@ -1264,6 +1264,7 @@ int PHYSFS_mkdir(const char *dname)
char *start;
char *end;
int retval = 0;
int exists = 1; /* force existance check on first path element. */

BAIL_IF_MACRO(dname == NULL, ERR_INVALID_ARGUMENT, 0);
while (*dname == '/')
@@ -1279,14 +1280,15 @@ int PHYSFS_mkdir(const char *dname)

while (1)
{
int already_exists;

end = strchr(start, '/');
if (end != NULL)
*end = '\0';

retval = h->funcs->isDirectory(h, str, &already_exists);
if ((!retval) && (!already_exists))
/* only check for existance if all parent dirs existed, too... */
if (exists)
retval = h->funcs->isDirectory(h, str, &exists);

if (!exists)
retval = h->funcs->mkdir(h, str);

if (!retval)

0 comments on commit 3744f54

Please sign in to comment.