void FileManager::OnInit() { #if defined(WINDOWS_TARGET) int ret = PHYSFS_init(s_exePath); #elif defined(EMSCRIPTEN_TARGET) int ret = PHYSFS_init("/"); #endif assert(ret); #if defined(WINDOWS_TARGET) if(PHYSFS_mount("\\data\\", "/data", 0) == 0) { assert(false); } #elif defined(EMSCRIPTEN_TARGET) if(PHYSFS_mount("/data", "/data", 0) == 0) { //printf("%s\n", PHYSFS_getLastError()); assert(false); } #else #endif //FILE* file = fopen("data/idle-0.png", "r"); //assert(file); }
void init(const char* argv0, bool symLinks) { if (!PHYSFS_init(argv0)) throw Exception(PHYSFS_getLastError()); PHYSFS_permitSymbolicLinks(symLinks); }
void initPhysFS(const char* argv0) { static const char* mainArgv0 = argv0; deinitPhysFS(); PHYSFS_init(mainArgv0); PHYSFS_permitSymbolicLinks(1); }
FileSystem::FileSystem(const std::string& path) { assert(mFileSystemSingleton == 0); PHYSFS_init(path.c_str()); /// \todo do we need to check if this operation suceeded? mFileSystemSingleton = this; }
//================================================== //! Constructor //================================================== System::VFS::VFS() { // Initialize PhysicsFS PHYSFS_init( NULL ); // Hardcoded paths for now PHYSFS_addToSearchPath( "/Users/aaron/Documents/Phaedrus-FPS/Resources/", 1 ); }
bool j1FileSystem::Awake() { bool ret = true; LOG("Init File System event system"); PHYSFS_init(NULL); return ret; }
ZipFileSystem::ZipFileSystem(const String& filePath, const String& root) : mRoot(root){ PHYSFS_init(NULL); // TODO handle root directory PHYSFS_addToSearchPath(filePath.c_str(), 0); }
void init(const char* argv0) { rmt_CreateGlobalInstance(&rmt); PHYSFS_init(argv0); PHYSFS_mount("AppData", 0, 1); PHYSFS_mount("../AppData", 0, 1); PHYSFS_mount("../../AppData", 0, 1); if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER)<0) { fprintf(stderr, "Unable to open SDL: %s\n", SDL_GetError()); ::exit(1); } SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 ); SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 ); SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 ); SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8 ); SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 24 ); SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 8 ); SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, TRUE ); SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 ); SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, 4 ); SDL_GL_SetAttribute( SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, 1 ); SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, 4 ); SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 4 ); SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE ); #ifdef _DEBUG SDL_GL_SetAttribute( SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG ); #endif window = SDL_CreateWindow( "", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE ); if(!window) { fprintf(stderr, "Unable to create window: %s\n", SDL_GetError()); ::exit(1); } context = SDL_GL_CreateContext(window); importOpenGL(); core::init(); gfx::init(1280, 720); ui::init(1280, 720); app::init(); notifyResize(1280, 720); prevTime = timerAbsoluteTime(); runLoop = true; recompileGLPrograms = false; }
bool gInit (int sdlflags, int repeat_delay, int repeat_interval, const char *argv0) { if(SDL_Init(sdlflags|SDL_INIT_VIDEO|SDL_INIT_TIMER) == -1) { gLogf("SDL_Init failed: %s\n", SDL_GetError()); return false; } SDL_EnableUNICODE(1); SDL_EnableKeyRepeat(repeat_delay, repeat_interval); if(TTF_Init()==-1) { gLogf("TTF_Init failed: %s\n", TTF_GetError()); return false; } if(!PHYSFS_init(argv0)) { gLogf("PHYSFS_init failed: %s\n", PHYSFS_getLastError()); return false; } return true; }
util::VersionInfo Application::initPhysFS(const std::string& arg0) { PHYSFS_Version ver; PHYSFS_init(arg0.c_str()); PHYSFS_addToSearchPath(PHYSFS_getBaseDir(),0); PHYSFS_getLinkedVersion(&ver); return util::VersionInfo(ver.major, ver.minor, ver.patch); }
ResourceCache::ResourceCache() { PHYSFS_init(NULL); PHYSFS_addToSearchPath("data/images.zip", 1); PHYSFS_addToSearchPath("data/sounds.zip", 1); al_init_image_addon(); al_init_acodec_addon(); al_set_physfs_file_interface(); }
void physfs_init(const char* binpath) { PHYSFS_init(binpath); // Add cwd PHYSFS_setWriteDir("."); PHYSFS_mount(".", NULL, 1); }
// Called before quitting bool j1Physfs::CleanUp() { LOG("Destroying Physfs lib"); PHYSFS_init(0); return true; }
physfsDrive::physfsDrive(const char * startdir,Bit16u _bytes_sector,Bit8u _sectors_cluster,Bit16u _total_clusters,Bit16u _free_clusters,Bit8u _mediaid) :localDrive(startdir,_bytes_sector,_sectors_cluster,_total_clusters,_free_clusters,_mediaid) { char newname[CROSS_LEN+1]; /* No writedir given, use capture directory */ if(startdir[0] == ':') { strcpy(newname,capturedir.c_str()); strcat(newname,startdir); } else { strcpy(newname,startdir); } CROSS_FILENAME(newname); if (!physfs_used) { PHYSFS_init(""); PHYSFS_permitSymbolicLinks(1); } physfs_used++; char *lastdir = newname; char *dir = strchr(lastdir+(((lastdir[0]|0x20) >= 'a' && (lastdir[0]|0x20) <= 'z')?2:0),':'); while (dir) { *dir++ = 0; if((lastdir == newname) && !strchr(dir+(((dir[0]|0x20) >= 'a' && (dir[0]|0x20) <= 'z')?2:0),':')) { // If the first parameter is a directory, the next one has to be the archive file, // do not confuse it with basedir if trailing : is not there! int tmp = strlen(dir)-1; dir[tmp++] = ':'; dir[tmp++] = CROSS_FILESPLIT; dir[tmp] = '\0'; } if (*lastdir && PHYSFS_addToSearchPath(lastdir,true) == 0) { LOG_MSG("PHYSFS couldn't add '%s': %s",lastdir,PHYSFS_getLastError()); } lastdir = dir; dir = strchr(lastdir+(((lastdir[0]|0x20) >= 'a' && (lastdir[0]|0x20) <= 'z')?2:0),':'); } const char *oldwrite = PHYSFS_getWriteDir(); if (oldwrite) oldwrite = strdup(oldwrite); if (!PHYSFS_setWriteDir(newname)) { if (!oldwrite) LOG_MSG("PHYSFS can't use '%s' for writing, you might encounter problems",newname); else PHYSFS_setWriteDir(oldwrite); } if (oldwrite) free((char *)oldwrite); strcpy(basedir,lastdir); allocation.bytes_sector=_bytes_sector; allocation.sectors_cluster=_sectors_cluster; allocation.total_clusters=_total_clusters; allocation.free_clusters=_free_clusters; allocation.mediaid=_mediaid; dirCache.SetBaseDir(basedir, this); }
CResourceManager::CResourceManager(const char *argv0) { if (!PHYSFS_init(argv0)) { GetLogger()->Error("Error while initializing physfs: %s\n", PHYSFS_getLastError()); assert(false); } PHYSFS_permitSymbolicLinks(1); }
/**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; }
DLL_API void InitDLL() { IToolBox *toolBox; toolBox = EngineGetToolBox(); static CHashString ZLSFName(_T("CZLibStreamFactory")); toolBox->CreateComponent( &ZLSFName, 0 ); PHYSFS_init( NULL ); }
int main(int argc, char **argv) { char filename[PATH_MAX]; char path[PATH_MAX], *delim; GAMEMAP *map; if (argc != 2) { printf("Usage: %s <map>\n", argv[0]); return -1; } strcpy(path, argv[1]); delim = strrchr(path, '/'); if (delim) { *delim = '\0'; delim++; strcpy(filename, delim); } else { path[1] = '.'; path[1] = '\0'; strcpy(filename, argv[1]); } PHYSFS_init(argv[0]); PHYSFS_addToSearchPath(path, 1); map = mapLoad(filename); if (map) { char tilesetName[PATH_MAX]; if (map->tileset == TILESET_ARIZONA) { strcpy(tilesetName, "Arizona"); } else if (map->tileset == TILESET_URBAN) { strcpy(tilesetName, "Urban"); } else if (map->tileset == TILESET_ROCKIES) { strcpy(tilesetName, "Rockies"); } else { strcpy(tilesetName, "(unknown)"); } printf("Loaded map: %s\n", filename); printf("\tMap version: %d\n", (int)map->mapVersion); printf("\tGame version: %d\n", (int)map->gameVersion); printf("\tWidth: %d\n", (int)map->width); printf("\tHeight: %d\n", (int)map->height); printf("\tGateways: %d\n", (int)map->numGateways); printf("\tPlayers: %d\n", (int)map->numPlayers); printf("\tFeatures: %d\n", (int)map->numFeatures); printf("\tDroids: %d\n", (int)map->numDroids); printf("\tStructures: %d\n", (int)map->numStructures); printf("\tScroll limits: (%d, %d, %d, %d)\n", (int)map->scrollMinX, (int)map->scrollMinY, (int)map->scrollMaxX, (int)map->scrollMaxY); printf("\tLevel name: %s\n", map->levelName); printf("\tTileset: %s\n", tilesetName); } mapFree(map); return 0; }
int main(int argc, char **argv) { int i, err; static char filename[4096]; lua_State *L = luaL_newstate(); luaL_openlibs(L); lua_newtable(L); for(i = 0; i < argc; i++) { lua_pushinteger(L, i + 1); lua_pushstring(L, argv[i]); lua_settable(L, -3); } lua_setglobal(L, "args"); lua_settop(L, 0); /* Temporarily initialize PhysicsFS so that we can append the base directory to package.cpath */ PHYSFS_init(argv[0]); lua_getglobal(L, "package"); lua_pushstring(L, PHYSFS_getBaseDir()); lua_pushstring(L, "?.so;"); lua_pushstring(L, PHYSFS_getDirSeparator()); lua_pushstring(L, "?.so;"); lua_getfield(L, -5, "cpath"); lua_concat(L, 5); lua_setfield(L, -2, "cpath"); lua_pushstring(L, PHYSFS_getBaseDir()); lua_pushstring(L, "?.dll;"); lua_pushstring(L, PHYSFS_getDirSeparator()); lua_pushstring(L, "?.dll;"); lua_getfield(L, -5, "cpath"); lua_concat(L, 5); lua_setfield(L, -2, "cpath"); lua_pop(L, 1); sprintf(filename, "%s%s%s", PHYSFS_getBaseDir(), PHYSFS_getDirSeparator(), "server"); PHYSFS_deinit(); if((err = luaL_dofile(L, filename))) { const char *message = lua_tostring(L, -1); fprintf(stderr, "Error: %s\n", message); return err; } lua_getglobal(L, "init"); if((err = lua_pcall(L, 0, 0, 0))) { const char *message = lua_tostring(L, -1); fprintf(stderr, "Error: %s\n", message); return err; } return 0; }
int fs_init(const char *argv0) { if (PHYSFS_init(argv0)) { PHYSFS_permitSymbolicLinks(1); return 1; } return 0; }
virtual void SetUp(void) { glfwInit(); glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE); window = glfwCreateWindow(TEST_WIDTH, TEST_HEIGHT, "gtest", nullptr, nullptr); glfwSetWindowPos(window, 300, 300); glfwMakeContextCurrent(window); ASSERT_EQ(GLEW_OK, glewInit()); PHYSFS_init("gtest"); PHYSFS_addToSearchPath("data", true); }
int main(int argc, char* argv[]) { PHYSFS_init(argv[0]); Editor* editor = Editor::getEditor(); if (editor!=0) editor->run(); return 0; }
/*! * Initialize the PhysicsFS library. */ static void initialize_PhysicsFS(const char* argv_0) { int result = PHYSFS_init(argv_0); if (!result) { debug(LOG_FATAL, "There was a problem trying to init Physfs. Error was %s", PHYSFS_getLastError()); exit(-1); } }
// Load the shared lib containing the core and calls te4main inside it, passing control to that core _te4_export char* find_te4_core(core_boot_type *core_def, const char *selfexe) { /****************************************************************** ** Find a core file ******************************************************************/ PHYSFS_init(selfexe); if (selfexe && PHYSFS_mount(selfexe, "/", 1)) {} else { printf("NO SELFEXE: bootstrapping from CWD\n"); PHYSFS_mount("bootstrap", "/bootstrap", 1); } lua_State *L = lua_open(); luaL_openlibs(L); luaopen_physfs(L); // Tell the boostrapping code the selfexe path if (selfexe) lua_pushstring(L, selfexe); else lua_pushnil(L); lua_setglobal(L, "__SELFEXE"); // Will be useful #ifdef __APPLE__ lua_pushboolean(L, 1); lua_setglobal(L, "__APPLE__"); #endif // Run bootstrapping if (!luaL_loadfile(L, "/bootstrap/boot.lua")) { lua_call(L, 0, 0); } // Could not load bootstrap! Try to mount the engine from working directory as last resort else { printf("Could not find bootstrapping code! Aborting!\n"); exit(1); } // Get the core lua_getglobal(L, "get_core"); if (core_def->coretype) lua_pushstring(L, core_def->coretype); else lua_pushnil(L); lua_pushnumber(L, core_def->corenum); lua_call(L, 2, 1); char *core = strdup((char*)lua_tostring(L, -1)); printf("Runner booting core: %s\n", core); lua_close(L); PHYSFS_deinit(); if (!core) { printf("No core found!"); exit(1); } return core; }
bool FileManager::init() { if (PHYSFS_isInit() != 0) return true; if (PHYSFS_init(getRoot().getArgs(0).c_str()) != 0) return true; Log::write(Log::Error, fmt::format("Unable to init PhysFS.")); return false; }
int ex_fsys_init () { __PHYSFS_CHECK( PHYSFS_init(".") ); // NOTE: we write like this to prevent compile error PHYSFS_permitSymbolicLinks(1); // yes, we permit symbolic links ex_log ( "[fsys] Version: %d.%d.%d", PHYSFS_VER_MAJOR, PHYSFS_VER_MINOR, PHYSFS_VER_PATCH ); return 0; }
j1FileSystem::j1FileSystem(const char* game_path) : j1Module() { name.create("file_system"); // need to be created before Awake so other modules can use it char* base_path = SDL_GetBasePath(); PHYSFS_init(base_path); SDL_free(base_path); AddPath("."); AddPath(game_path); }
Lux::Core::FileHandler::FileHandler() { int res = PHYSFS_init(nullptr); if (res == 0) { String errstr("Error initializing File System class : "); errstr.append(PHYSFS_getLastError()); Utility::ThrowError(errstr); } LUX_LOG(Utility::logINFO) << "File system created successfully."; }
FileSystem::FileSystem(const char *argv0, bool allowSymlinks) { p = new FileSystemPrivate; p->havePathCache = false; /* Image extensions */ p->extensions[Image].push_back("jpg"); p->extensions[Image].push_back("png"); /* Audio extensions */ const Sound_DecoderInfo **di; for (di = Sound_AvailableDecoders(); *di; ++di) { const char **ext; for (ext = (*di)->extensions; *ext; ++ext) { /* All reported extensions are uppercase, * so we need to hammer them down first */ char buf[16]; for (size_t i = 0; i < sizeof(buf); ++i) { buf[i] = tolower((*ext)[i]); if (!buf[i]) break; } p->extensions[Audio].push_back(buf); } } if (rgssVer >= 2 && !contains(p->extensions[Audio], std::string("ogg"))) p->extensions[Audio].push_back("ogg"); p->extensions[Audio].push_back("mid"); p->extensions[Audio].push_back("midi"); /* Font extensions */ p->extensions[Font].push_back("ttf"); p->extensions[Font].push_back("otf"); PHYSFS_init(argv0); PHYSFS_registerArchiver(&RGSS1_Archiver); PHYSFS_registerArchiver(&RGSS2_Archiver); PHYSFS_registerArchiver(&RGSS3_Archiver); if (allowSymlinks) PHYSFS_permitSymbolicLinks(1); }
int main(int argc, char *argv[]) { printf("Init physfs\n"); PHYSFS_init(argv[0]); PHYSFS_addToSearchPath(PHYSFS_getBaseDir(), 1); PHYSFS_addToSearchPath("data.7z", 1); printf("Init physfs end\n"); Main main; main.Execute(); return 0; }