#include <SDL.h>
#include <string>
Go to the source code of this file.
Functions | |
SDL_RWops * | get_physfs_SDLRWops (const std::string &filename) |
SDL_RWops* get_physfs_SDLRWops | ( | const std::string & | filename | ) |
Definition at line 71 of file physfs_sdl.cpp.
References funcClose(), funcRead(), and funcSeek().
Referenced by TextureManager::create_image_texture_raw(), Main::init_video(), and Font::loadFontSurface().
00072 { 00073 // check this as PHYSFS seems to be buggy and still returns a 00074 // valid pointer in this case 00075 if(filename == "") { 00076 throw std::runtime_error("Couldn't open file: empty filename"); 00077 } 00078 00079 PHYSFS_file* file = (PHYSFS_file*) PHYSFS_openRead(filename.c_str()); 00080 if(!file) { 00081 std::stringstream msg; 00082 msg << "Couldn't open '" << filename << "': " 00083 << PHYSFS_getLastError(); 00084 throw std::runtime_error(msg.str()); 00085 } 00086 00087 SDL_RWops* ops = new SDL_RWops(); 00088 ops->type = 0; 00089 ops->hidden.unknown.data1 = file; 00090 ops->seek = funcSeek; 00091 ops->read = funcRead; 00092 ops->write = 0; 00093 ops->close = funcClose; 00094 return ops; 00095 }