physfs.c
changeset 122 402ee2bf165c
parent 103 cb5f60383994
child 126 f5135b499c0c
equal deleted inserted replaced
121:86deec2e27d9 122:402ee2bf165c
   650     BAIL_IF_MACRO(str == NULL, ERR_OUT_OF_MEMORY, 0);
   650     BAIL_IF_MACRO(str == NULL, ERR_OUT_OF_MEMORY, 0);
   651     sprintf(str, "%s.%s%s%s", userdir, organization, dirsep, appName);
   651     sprintf(str, "%s.%s%s%s", userdir, organization, dirsep, appName);
   652 
   652 
   653     if (!PHYSFS_setWriteDir(str))
   653     if (!PHYSFS_setWriteDir(str))
   654     {
   654     {
       
   655         int no_write = 0;
       
   656         sprintf(str, ".%s/%s", organization, appName);
   655         if ( (PHYSFS_setWriteDir(userdir)) &&
   657         if ( (PHYSFS_setWriteDir(userdir)) &&
   656              (PHYSFS_mkdir(str + strlen(userdir))) )
   658              (PHYSFS_mkdir(str)) )
   657         {
   659         {
   658             PHYSFS_setWriteDir(str);
   660             sprintf(str, "%s.%s%s%s", userdir, organization, dirsep, appName);
       
   661             if (!PHYSFS_setWriteDir(str))
       
   662                 no_write = 1;
   659         } /* if */
   663         } /* if */
   660         else
   664         else
   661         {
   665         {
   662             PHYSFS_setWriteDir(NULL);
   666                 no_write = 1;
       
   667         } /* else */
       
   668 
       
   669         if (no_write)
       
   670         {
       
   671             PHYSFS_setWriteDir(NULL);   /* just in case. */
   663             free(str);
   672             free(str);
   664             BAIL_IF_MACRO(1, ERR_CANT_SET_WRITE_DIR, 0);
   673             BAIL_MACRO(ERR_CANT_SET_WRITE_DIR, 0);
   665         } /* else */
   674         } /* if */
   666     } /* if */
   675     } /* if */
   667 
   676 
   668     /* Put write dir first in search path... */
   677     /* Put write dir first in search path... */
   669     PHYSFS_addToSearchPath(str, 0);
   678     PHYSFS_addToSearchPath(str, 0);
   670     free(str);
   679     free(str);