diff options
Diffstat (limited to 'src/filesystem/diskfile.cc')
-rw-r--r-- | src/filesystem/diskfile.cc | 44 |
1 files changed, 9 insertions, 35 deletions
diff --git a/src/filesystem/diskfile.cc b/src/filesystem/diskfile.cc index a01a327..56e2727 100644 --- a/src/filesystem/diskfile.cc +++ b/src/filesystem/diskfile.cc @@ -4,6 +4,7 @@ the terms of the GNU General Public License version 2 */ +#include "filesystem/filesystem.h" #include "filesystem/diskfile.h" namespace filesystem { @@ -27,46 +28,19 @@ bool DiskFile::open(const char *filename) } file_name.assign(filename); - std::string fn; - - // if moddir is set, try the mods subdir first - if (moddir.size()) { - // try homedir + moddir - file_path = homedir; - file_path.append(moddir); - fn = file_path; - fn.append(filename); - diskfile_handle = fopen(fn.c_str(), "rb"); - if (diskfile_handle) - return true; + file_path.clear(); - // try datadir + moddir - file_path = datadir; - file_path.append(moddir); - fn = file_path; + for (SearchPath::iterator path = searchpath().begin(); path != searchpath().end(); path++) { + std::string fn((*path)); fn.append(filename); + diskfile_handle = fopen(fn.c_str(), "rb"); - if (diskfile_handle) + if (diskfile_handle) { + file_path.assign((*path)); return true; - } - // try homedir + basedir - file_path = homedir; - file_path.append(basedir); - fn = file_path; - fn.append(filename); - diskfile_handle = fopen(fn.c_str(), "rb"); - if (diskfile_handle) - return true; + } + } - // try datadir + basedir - file_path = datadir; - file_path.append(basedir); - fn = file_path; - fn.append(filename); - diskfile_handle = fopen(fn.c_str(), "rb"); - if (diskfile_handle) - return true; - //con_error << "Could not open " << filename << std::endl; return false; } |