static int cmd_setsaneconfig(char *args) { char *org; char *appName; char *arcExt; int inclCD; int arcsFirst; char *ptr = args; /* ugly. */ org = ptr; ptr = strchr(ptr, ' '); *ptr = '\0'; ptr++; appName = ptr; ptr = strchr(ptr, ' '); *ptr = '\0'; ptr++; arcExt = ptr; ptr = strchr(ptr, ' '); *ptr = '\0'; ptr++; inclCD = atoi(arcExt); arcsFirst = atoi(ptr); if (strcmp(arcExt, "!") == 0) arcExt = NULL; if (PHYSFS_setSaneConfig(org, appName, arcExt, inclCD, arcsFirst)) printf("Successful.\n"); else printf("Failure. reason: %s.\n", PHYSFS_getLastError()); return(1); } /* cmd_setsaneconfig */
/**Initialize the PhysFS system with some default configuration. * The write directory is set to $HOME/.Games/Epiar * The search path is set to * - The write directory * - The directory of the current executeable * - Any archives found in the path (must pass in the extension) * \return Nonzero on success. */ int Filesystem::Init( const char* argv0, const string &extension ) { int retval; if ( (retval = PHYSFS_init(argv0)) == 0 ) LogMsg(ERR,"Error initializing PhysicsFS.\n%s",PHYSFS_getLastError()); if ( (retval = PHYSFS_setSaneConfig("Games","Epiar", extension.c_str(),0,1) == 0) ) LogMsg(ERR,"Error initializing PhysicsFS configuration.\n%s",PHYSFS_getLastError()); return retval; }
void setSaneConfig(const std::string& organisation, const std::string& appName, const std::string& archiveExt, bool includeCdDrives, bool archivesFirst) { if (!PHYSFS_setSaneConfig(organisation.c_str(), appName.c_str(), archiveExt.c_str(), includeCdDrives, archivesFirst)) { throw Exception(PHYSFS_getLastError()); } }
void SetupUserDir(std::string path) { if (HasSetUserDir()) return; // Don't call PHYSFS_setSaneConfig twice if (!IsLoaded()) { Logger::begin("Filesystem", Logger::LogLevel_Error) << "FS not loaded" << Logger::end(); assert(false); return; } PHYSFS_setSaneConfig("Engine2D", path.c_str(), NULL, 0, 0); hasSetUserDir = true; }
/**Initialize the PhysFS system * \return Nonzero on success. */ int Filesystem::Init( const char* argv0 ) { int retval; if ( (retval = PHYSFS_init(argv0)) == 0 ) LogMsg(ERR,"Error initializing PhysicsFS. Reason: %s\n",PHYSFS_getLastError()); if ( (retval = PHYSFS_setSaneConfig("games", "epiar", NULL, 0, 0 ) ) == 0 ) LogMsg(ERR,"Could not set sane paths for PhysFS: %s\n", PHYSFS_getLastError()); // Set up userDir if ( (retval = PHYSFS_mkdir("Resources/Definitions/") ) == 0 ) LogMsg(ERR,"Could not set up the user dir: %s\n", PHYSFS_getLastError()); #ifdef DATADIR // If using autotools, include this prefix to help binary find data files for cases where 'make install' was used if ( (retval = PHYSFS_addToSearchPath(DATADIR, 1)) == 0 ) LogMsg(INFO,"Not using DATADIR directory due to error, probably 'make install' not run yet. Reason: %s\n", PHYSFS_getLastError()); #endif /* DATADIR */ return retval; }
void setSaneConfig(const string& orgName, const string& appName, const string& archiveExt, bool includeCdRoms, bool archivesFirst) { PHYSFS_setSaneConfig(orgName.c_str(), appName.c_str(), archiveExt.c_str(), includeCdRoms, archivesFirst); }
Resource::Resource(char* argv0) : m_resources() { PHYSFS_init(argv0); PHYSFS_setSaneConfig("nyaxix", "ideal-trigger", "zip", 0, 1); }
int main(int argc, char *argv[]) { SDL_Event event; double time, lasttime; int i, length, x, y; bool done; /* Hethrep: Remove traps for signals if DEBUG env var is set * so print_backtrace doesn't get called anymore, * this allows proper coredumps and backtraces for SIGSEGV. * print_backtrace is mostly useless but cleans up after a crash, * so it is useful for users, but bad for backtracing / debugging. */ #ifndef DEBUG if(NULL == getenv("DEBUG")) { signal(SIGILL, print_backtrace); signal(SIGQUIT, print_backtrace); signal(SIGABRT, print_backtrace); signal(SIGFPE, print_backtrace); signal(SIGSEGV, print_backtrace); signal(SIGBUS, print_backtrace); #ifdef SIGSYS signal(SIGSYS, print_backtrace); #endif printf("traps installed\n"); } else #endif printf("DEBUG enabled\n"); Completion_Init(); System_Init(); //Big: PhysFS init needs the command line PHYSFS_init(argv[0]); PHYSFS_setSaneConfig("savage", "", NULL, 0, 0); length = 1; for (i = 0; i < argc; i++) length += 1 + strlen(argv[i]); sys_cmdline = Tag_Malloc(length, MEM_SYSTEM); strcpy(sys_cmdline, ""); for (i = 0; i < argc; i++) { strcat(sys_cmdline, argv[i]); strcat(sys_cmdline, " "); } signal(SIGCHLD, killchild); /* this eliminates zombies */ Host_Init(); Cmd_Register("launchurl", &LaunchURL_cmd); //hash the file once it's already opened, to make a file switch harder //engine_hashlen = Hash_Filename(argv[0], (unsigned char*)engine_hash); lasttime = System_Milliseconds(); sys_time = 0; SDL_EnableUNICODE(sys_useUnicode.integer); #ifdef linux Clipboard_Init(); #endif while(1) { int elapsed; if (!sys_forcefocus.integer && (dedicated_server.integer || sys_sleep.integer || !sys_focus.integer)) System_Sleep(1); //allow time for other processes //the following loop is necessary because System_GetTime() - lasttime could be dangerously close to 0 do { time = System_Milliseconds(); } while (time-lasttime < 1); elapsed = (time-lasttime); if (gfx.integer) { ResetButtonData(); /* Check if there's a pending event. */ while( SDL_PollEvent( &event ) ) { done = HandleEvent(&event); } SDL_GetMouseState(&x, &y); //if(y != Vid_GetScreenH()>>1 && x != Vid_GetScreenW()>>1) { if (inverty.integer) y = Vid_GetScreenH() - y; Input_UpdateMouse(x, y); //} } if (sys_useUnicode.modified) { SDL_EnableUNICODE(sys_useUnicode.integer); sys_useUnicode.modified = false; } sys_time += elapsed; Host_Frame((float)elapsed); lasttime = time; } return TRUE; //this will never get called }