Skip to content

Commit

Permalink
Minor brainfart fix in verifySecurity() and optimized mkdir().
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Mar 19, 2003
1 parent 8bdc0ea commit 3744f54
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions physfs.c
Expand Up @@ -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 */
Expand All @@ -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 == '/')
Expand All @@ -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)
Expand Down

0 comments on commit 3744f54

Please sign in to comment.