FileSystem: Allow ::openReadRaw() to break out of game directory
If PhysFS fails to open a path, fall back to simple FILE* handles. Not sure yet if this is a good idea, but from observation RMXP allows load_data() to operate on paths outside the game directory as well, so we have to support this.
This commit is contained in:
		
							parent
							
								
									7938a07539
								
							
						
					
					
						commit
						d45a400227
					
				
					 5 changed files with 33 additions and 40 deletions
				
			
		| 
						 | 
				
			
			@ -33,7 +33,6 @@ fileIntFreeInstance(void *inst)
 | 
			
		|||
{
 | 
			
		||||
	SDL_RWops *ops = static_cast<SDL_RWops*>(inst);
 | 
			
		||||
 | 
			
		||||
	SDL_RWclose(ops);
 | 
			
		||||
	SDL_FreeRW(ops);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -42,16 +41,14 @@ DEF_TYPE_CUSTOMFREE(FileInt, fileIntFreeInstance);
 | 
			
		|||
static VALUE
 | 
			
		||||
fileIntForPath(const char *path, bool rubyExc)
 | 
			
		||||
{
 | 
			
		||||
	SDL_RWops *ops = SDL_AllocRW();
 | 
			
		||||
	SDL_RWops *ops;
 | 
			
		||||
 | 
			
		||||
	try
 | 
			
		||||
	{
 | 
			
		||||
		shState->fileSystem().openReadRaw(*ops, path);
 | 
			
		||||
		ops = shState->fileSystem().openReadRaw(path);
 | 
			
		||||
	}
 | 
			
		||||
	catch (const Exception &e)
 | 
			
		||||
	{
 | 
			
		||||
		SDL_FreeRW(ops);
 | 
			
		||||
 | 
			
		||||
		if (rubyExc)
 | 
			
		||||
			raiseRbExc(e);
 | 
			
		||||
		else
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue