PHYSFS_setSaneConfig() now uses PHYSFS_getPrefDir().
This commit is contained in:
parent
24d6a925d1
commit
3a5a780988
51
src/physfs.c
51
src/physfs.c
|
@ -1679,66 +1679,37 @@ int PHYSFS_setSaneConfig(const char *organization, const char *appName,
|
||||||
const char *archiveExt, int includeCdRoms,
|
const char *archiveExt, int includeCdRoms,
|
||||||
int archivesFirst)
|
int archivesFirst)
|
||||||
{
|
{
|
||||||
const char *basedir = PHYSFS_getBaseDir();
|
|
||||||
const char *userdir = PHYSFS_getUserDir();
|
|
||||||
const char *dirsep = PHYSFS_getDirSeparator();
|
const char *dirsep = PHYSFS_getDirSeparator();
|
||||||
PHYSFS_uint64 len = 0;
|
const char *basedir;
|
||||||
char *str = NULL;
|
const char *prefdir;
|
||||||
|
|
||||||
BAIL_IF_MACRO(!initialized, PHYSFS_ERR_NOT_INITIALIZED, 0);
|
BAIL_IF_MACRO(!initialized, PHYSFS_ERR_NOT_INITIALIZED, 0);
|
||||||
|
|
||||||
/* set write dir... */
|
prefdir = PHYSFS_getPrefDir(organization, appName);
|
||||||
len = (strlen(userdir) + (strlen(organization) * 2) +
|
BAIL_IF_MACRO(!prefdir, ERRPASS, 0);
|
||||||
(strlen(appName) * 2) + (strlen(dirsep) * 3) + 2);
|
|
||||||
|
|
||||||
str = (char *) __PHYSFS_smallAlloc(len);
|
basedir = PHYSFS_getBaseDir();
|
||||||
|
BAIL_IF_MACRO(!basedir, ERRPASS, 0);
|
||||||
|
|
||||||
BAIL_IF_MACRO(!str, PHYSFS_ERR_OUT_OF_MEMORY, 0);
|
BAIL_IF_MACRO(!PHYSFS_setWriteDir(prefdir), PHYSFS_ERR_NO_WRITE_DIR, 0);
|
||||||
sprintf(str, "%s.%s%s%s", userdir, organization, dirsep, appName);
|
|
||||||
|
|
||||||
if (!PHYSFS_setWriteDir(str))
|
|
||||||
{
|
|
||||||
int no_write = 0;
|
|
||||||
sprintf(str, ".%s/%s", organization, appName);
|
|
||||||
if ( (PHYSFS_setWriteDir(userdir)) &&
|
|
||||||
(PHYSFS_mkdir(str)) )
|
|
||||||
{
|
|
||||||
sprintf(str, "%s.%s%s%s", userdir, organization, dirsep, appName);
|
|
||||||
if (!PHYSFS_setWriteDir(str))
|
|
||||||
no_write = 1;
|
|
||||||
} /* if */
|
|
||||||
else
|
|
||||||
{
|
|
||||||
no_write = 1;
|
|
||||||
} /* else */
|
|
||||||
|
|
||||||
if (no_write)
|
|
||||||
{
|
|
||||||
PHYSFS_setWriteDir(NULL); /* just in case. */
|
|
||||||
__PHYSFS_smallFree(str);
|
|
||||||
BAIL_MACRO(PHYSFS_ERR_NO_WRITE_DIR, 0);
|
|
||||||
} /* if */
|
|
||||||
} /* if */
|
|
||||||
|
|
||||||
/* Put write dir first in search path... */
|
/* Put write dir first in search path... */
|
||||||
PHYSFS_mount(str, NULL, 0);
|
PHYSFS_mount(prefdir, NULL, 0);
|
||||||
__PHYSFS_smallFree(str);
|
|
||||||
|
|
||||||
/* Put base path on search path... */
|
/* Put base path on search path... */
|
||||||
PHYSFS_mount(basedir, NULL, 1);
|
PHYSFS_mount(basedir, NULL, 1);
|
||||||
|
|
||||||
/* handle CD-ROMs... */
|
/* handle CD-ROMs... */
|
||||||
if (includeCdRoms)
|
if (includeCdRoms)
|
||||||
{
|
{
|
||||||
char **cds = PHYSFS_getCdRomDirs();
|
char **cds = PHYSFS_getCdRomDirs();
|
||||||
char **i;
|
char **i;
|
||||||
for (i = cds; *i != NULL; i++)
|
for (i = cds; *i != NULL; i++)
|
||||||
PHYSFS_mount(*i, NULL, 1);
|
PHYSFS_mount(*i, NULL, 1);
|
||||||
|
|
||||||
PHYSFS_freeList(cds);
|
PHYSFS_freeList(cds);
|
||||||
} /* if */
|
} /* if */
|
||||||
|
|
||||||
/* Root out archives, and add them to search path... */
|
/* Root out archives, and add them to search path... */
|
||||||
if (archiveExt != NULL)
|
if (archiveExt != NULL)
|
||||||
{
|
{
|
||||||
char **rc = PHYSFS_enumerateFiles("/");
|
char **rc = PHYSFS_enumerateFiles("/");
|
||||||
|
|
Loading…
Reference in New Issue