Skip to content

Commit

Permalink
Fixed basedir/userdir calculation.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Jul 27, 2002
1 parent b5bc50b commit ece998d
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion platform/os2.c
Expand Up @@ -230,14 +230,27 @@ int __PHYSFS_platformInit(void)
APIRET rc;
PTIB ptib;
PPIB ppib;
PHYSFS_sint32 len;

assert(baseDir == NULL);

BAIL_IF_MACRO(os2err(DosGetInfoBlocks(&ptib, &ppib)) != NO_ERROR, NULL, 0);
rc = DosQueryModuleName(ppib->pib_hmte, sizeof (buf), (PCHAR) buf);
BAIL_IF_MACRO(os2err(rc) != NO_ERROR, NULL, 0);

baseDir = (char *) malloc(strlen(buf) + 1);
/* chop off filename, leave path. */
for (len = strlen(buf) - 1; len >= 0; len--)
{
if (buf[len] == '\\')
{
buf[++len] = '\0';
break;
} /* if */
} /* for */

assert(len > 0); /* should have been an "x:\\" on the front on string. */

baseDir = (char *) malloc(len + 1);
BAIL_IF_MACRO(baseDir == NULL, ERR_OUT_OF_MEMORY, 0);
strcpy(baseDir, buf);

Expand Down

0 comments on commit ece998d

Please sign in to comment.