diff options
| author | Einar Johan Trøan Sømåen | 2012-07-22 21:02:25 +0200 | 
|---|---|---|
| committer | Einar Johan Trøan Sømåen | 2012-07-22 21:02:25 +0200 | 
| commit | a549977cffae9a5f1be41d9b07d42908648e8f6d (patch) | |
| tree | 81af3890789f3dd3bdb96a05cee522abc29b7561 | |
| parent | c8b1c747242df4d8c596873ee320d64583380be0 (diff) | |
| download | scummvm-rg350-a549977cffae9a5f1be41d9b07d42908648e8f6d.tar.gz scummvm-rg350-a549977cffae9a5f1be41d9b07d42908648e8f6d.tar.bz2 scummvm-rg350-a549977cffae9a5f1be41d9b07d42908648e8f6d.zip | |
WINTERMUTE: Use FSNodes to parse relative paths used by the games.
| -rw-r--r-- | engines/wintermute/base/file/base_disk_file.cpp | 28 | 
1 files changed, 26 insertions, 2 deletions
| diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp index b4653c2c80..d1a8f02fa5 100644 --- a/engines/wintermute/base/file/base_disk_file.cpp +++ b/engines/wintermute/base/file/base_disk_file.cpp @@ -37,6 +37,8 @@  #include "common/file.h"
  #include "common/zlib.h"
  #include "common/archive.h"
 +#include "common/tokenizer.h"
 +#include "common/config-manager.h"
  namespace WinterMute {
 @@ -50,7 +52,7 @@ Common::SeekableReadStream *openDiskFile(const Common::String &filename, BaseFil  	char fullPath[MAX_PATH_LENGTH];
  	uint32 prefixSize = 0;
  	Common::SeekableReadStream *file = NULL;
 -
 +	// Try directly from SearchMan first
  	Common::ArchiveMemberList files;
  	SearchMan.listMatchingMembers(files, filename);
 @@ -60,7 +62,29 @@ Common::SeekableReadStream *openDiskFile(const Common::String &filename, BaseFil  			break;
  		}
  	}
 -
 +	// The filename can be an explicit path, thus we need to chop it up, expecting the path the game
 +	// specifies to follow the Windows-convention of folder\subfolder\file (absolute paths should not happen)
 +	if (!file) {
 +		if (filename.contains(':'))
 +			error("openDiskFile::Absolute path or invalid filename used in %s", filename.c_str());
 +		if (filename.contains('\\')) {
 +			Common::StringTokenizer path(filename, "\\");
 +
 +			const Common::FSNode gameDataDir(ConfMan.get("path"));
 +			Common::FSNode curNode = gameDataDir;
 +			while (!path.empty()) {
 +				Common::String pathPart = path.nextToken();
 +				Common::FSNode nextNode(curNode.getChild(pathPart));
 +				if (nextNode.exists() && nextNode.isReadable()) {
 +					curNode = nextNode;
 +				}
 +				if (!curNode.isDirectory()) {
 +					file = curNode.createReadStream();
 +					break;
 +				}
 +			}
 +		}
 +	}
  	if (file) {
  		uint32 magic1, magic2;
  		magic1 = file->readUint32LE();
 | 
