X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=source%2FIrrlicht%2FCFileSystem.cpp;h=3ee35d9b5a073e03f84b5baed29f131f929949ad;hb=25a7074c9af510b6d93d8e84309997e45bad094f;hp=7ba441f6001cf4774dadfef7738faf3f80405f63;hpb=4ab3de3bab13c18bc0eed6bac565be3b80ebac10;p=irrlicht.git diff --git a/source/Irrlicht/CFileSystem.cpp b/source/Irrlicht/CFileSystem.cpp index 7ba441f..3ee35d9 100644 --- a/source/Irrlicht/CFileSystem.cpp +++ b/source/Irrlicht/CFileSystem.cpp @@ -2,34 +2,29 @@ // This file is part of the "Irrlicht Engine". // For conditions of distribution and use, see copyright notice in irrlicht.h -#include "IrrCompileConfig.h" #include "CFileSystem.h" #include "IReadFile.h" #include "IWriteFile.h" #include "CZipReader.h" -#include "CMountPointReader.h" #include "CFileList.h" #include "stdio.h" #include "os.h" -#include "CAttributes.h" #include "CReadFile.h" #include "CMemoryFile.h" #include "CLimitReadFile.h" #include "CWriteFile.h" -#include "irrList.h" +#include #if defined (__STRICT_ANSI__) #error Compiling with __STRICT_ANSI__ not supported. g++ does set this when compiling with -std=c++11 or -std=c++0x. Use instead -std=gnu++11 or -std=gnu++0x. Or use -U__STRICT_ANSI__ to disable strict ansi. #endif #if defined (_IRR_WINDOWS_API_) - #if !defined ( _WIN32_WCE ) - #include // for _chdir - #include // for _access - #include - #endif -#elif (defined(_IRR_POSIX_API_) || defined(_IRR_OSX_PLATFORM_) || defined(_IRR_IOS_PLATFORM_) || defined(_IRR_ANDROID_PLATFORM_)) + #include // for _chdir + #include // for _access + #include +#elif (defined(_IRR_POSIX_API_) || defined(_IRR_OSX_PLATFORM_) || defined(_IRR_ANDROID_PLATFORM_)) #include #include #include @@ -58,29 +53,7 @@ CFileSystem::CFileSystem() //! reset current working directory getWorkingDirectory(); -#ifdef __IRR_COMPILE_WITH_PAK_ARCHIVE_LOADER_ - ArchiveLoader.push_back(new CArchiveLoaderPAK(this)); -#endif - -#ifdef __IRR_COMPILE_WITH_NPK_ARCHIVE_LOADER_ - ArchiveLoader.push_back(new CArchiveLoaderNPK(this)); -#endif - -#ifdef __IRR_COMPILE_WITH_TAR_ARCHIVE_LOADER_ - ArchiveLoader.push_back(new CArchiveLoaderTAR(this)); -#endif - -#ifdef __IRR_COMPILE_WITH_WAD_ARCHIVE_LOADER_ - ArchiveLoader.push_back(new CArchiveLoaderWAD(this)); -#endif - -#ifdef __IRR_COMPILE_WITH_MOUNT_ARCHIVE_LOADER_ - ArchiveLoader.push_back(new CArchiveLoaderMount(this)); -#endif - -#ifdef __IRR_COMPILE_WITH_ZIP_ARCHIVE_LOADER_ ArchiveLoader.push_back(new CArchiveLoaderZIP(this)); -#endif } @@ -222,8 +195,6 @@ bool CFileSystem::addFileArchive(const io::path& filename, bool ignoreCase, bool ret = false; // see if archive is already added - if (changeArchivePassword(filename, password, retArchive)) - return true; s32 i; @@ -319,29 +290,6 @@ bool CFileSystem::addFileArchive(const io::path& filename, bool ignoreCase, return ret; } -// don't expose! -bool CFileSystem::changeArchivePassword(const path& filename, - const core::stringc& password, - IFileArchive** archive) -{ - for (s32 idx = 0; idx < (s32)FileArchives.size(); ++idx) - { - // TODO: This should go into a path normalization method - // We need to check for directory names with trailing slash and without - const path absPath = getAbsolutePath(filename); - const path arcPath = FileArchives[idx]->getFileList()->getPath(); - if ((absPath == arcPath) || ((absPath+_IRR_TEXT("/")) == arcPath)) - { - if (password.size()) - FileArchives[idx]->Password=password; - if (archive) - *archive = FileArchives[idx]; - return true; - } - } - - return false; -} bool CFileSystem::addFileArchive(IReadFile* file, bool ignoreCase, bool ignorePaths, E_FILE_ARCHIVE_TYPE archiveType, @@ -352,9 +300,6 @@ bool CFileSystem::addFileArchive(IReadFile* file, bool ignoreCase, if (file) { - if (changeArchivePassword(file->getFileName(), password, retArchive)) - return true; - IFileArchive* archive = 0; s32 i; @@ -515,15 +460,9 @@ const io::path& CFileSystem::getWorkingDirectory() { #if defined(_IRR_WINDOWS_API_) fschar_t tmp[_MAX_PATH]; - #if defined(_IRR_WCHAR_FILESYSTEM ) - _wgetcwd(tmp, _MAX_PATH); - WorkingDirectory[FILESYSTEM_NATIVE] = tmp; - WorkingDirectory[FILESYSTEM_NATIVE].replace(L'\\', L'/'); - #else _getcwd(tmp, _MAX_PATH); WorkingDirectory[FILESYSTEM_NATIVE] = tmp; WorkingDirectory[FILESYSTEM_NATIVE].replace('\\', '/'); - #endif #endif #if (defined(_IRR_POSIX_API_) || defined(_IRR_OSX_PLATFORM_)) @@ -532,21 +471,6 @@ const io::path& CFileSystem::getWorkingDirectory() // so try it until the call was successful // Note that neither the first nor the second parameter may be 0 according to POSIX - #if defined(_IRR_WCHAR_FILESYSTEM ) - u32 pathSize=256; - wchar_t *tmpPath = new wchar_t[pathSize]; - while ((pathSize < (1<<16)) && !(wgetcwd(tmpPath,pathSize))) - { - delete [] tmpPath; - pathSize *= 2; - tmpPath = new char[pathSize]; - } - if (tmpPath) - { - WorkingDirectory[FILESYSTEM_NATIVE] = tmpPath; - delete [] tmpPath; - } - #else u32 pathSize=256; char *tmpPath = new char[pathSize]; while ((pathSize < (1<<16)) && !(getcwd(tmpPath,pathSize))) @@ -560,7 +484,6 @@ const io::path& CFileSystem::getWorkingDirectory() WorkingDirectory[FILESYSTEM_NATIVE] = tmpPath; delete [] tmpPath; } - #endif #endif WorkingDirectory[type].validate(); @@ -587,17 +510,9 @@ bool CFileSystem::changeWorkingDirectoryTo(const io::path& newDirectory) WorkingDirectory[FILESYSTEM_NATIVE] = newDirectory; #if defined(_MSC_VER) - #if defined(_IRR_WCHAR_FILESYSTEM) - success = (_wchdir(newDirectory.c_str()) == 0); - #else success = (_chdir(newDirectory.c_str()) == 0); - #endif #else - #if defined(_IRR_WCHAR_FILESYSTEM) - success = (_wchdir(newDirectory.c_str()) == 0); - #else success = (chdir(newDirectory.c_str()) == 0); - #endif #endif } @@ -612,15 +527,9 @@ io::path CFileSystem::getAbsolutePath(const io::path& filename) const #if defined(_IRR_WINDOWS_API_) fschar_t *p=0; fschar_t fpath[_MAX_PATH]; - #if defined(_IRR_WCHAR_FILESYSTEM ) - p = _wfullpath(fpath, filename.c_str(), _MAX_PATH); - core::stringw tmp(p); - tmp.replace(L'\\', L'/'); - #else p = _fullpath(fpath, filename.c_str(), _MAX_PATH); core::stringc tmp(p); tmp.replace('\\', '/'); - #endif return tmp; #elif (defined(_IRR_POSIX_API_) || defined(_IRR_OSX_PLATFORM_)) c8* p=0; @@ -753,11 +662,10 @@ path CFileSystem::getRelativeFilename(const path& filename, const path& director io::path path1, file, ext; core::splitFilename(getAbsolutePath(filename), &path1, &file, &ext); io::path path2(getAbsolutePath(directory)); - core::list list1, list2; + std::list list1, list2; path1.split(list1, _IRR_TEXT("/\\"), 2); path2.split(list2, _IRR_TEXT("/\\"), 2); - u32 i=0; - core::list::ConstIterator it1,it2; + std::list::const_iterator it1,it2; it1=list1.begin(); it2=list2.begin(); @@ -781,19 +689,19 @@ path CFileSystem::getRelativeFilename(const path& filename, const path& director #endif - for (; i