// This file is part of the "Irrlicht Engine".\r
// For conditions of distribution and use, see copyright notice in irrlicht.h\r
\r
-#include "IrrCompileConfig.h"\r
\r
#include "CFileSystem.h"\r
#include "IReadFile.h"\r
#include "IWriteFile.h"\r
#include "CZipReader.h"\r
-#include "CMountPointReader.h"\r
#include "CFileList.h"\r
#include "stdio.h"\r
#include "os.h"\r
-#include "CAttributes.h"\r
#include "CReadFile.h"\r
#include "CMemoryFile.h"\r
#include "CLimitReadFile.h"\r
#include "CWriteFile.h"\r
-#include "irrList.h"\r
+#include <list>\r
\r
#if defined (__STRICT_ANSI__)\r
#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.\r
#endif\r
\r
#if defined (_IRR_WINDOWS_API_)\r
- #if !defined ( _WIN32_WCE )\r
- #include <direct.h> // for _chdir\r
- #include <io.h> // for _access\r
- #include <tchar.h>\r
- #endif\r
-#elif (defined(_IRR_POSIX_API_) || defined(_IRR_OSX_PLATFORM_) || defined(_IRR_IOS_PLATFORM_) || defined(_IRR_ANDROID_PLATFORM_))\r
+ #include <direct.h> // for _chdir\r
+ #include <io.h> // for _access\r
+ #include <tchar.h>\r
+#elif (defined(_IRR_POSIX_API_) || defined(_IRR_OSX_PLATFORM_) || defined(_IRR_ANDROID_PLATFORM_))\r
#include <stdio.h>\r
#include <stdlib.h>\r
#include <string.h>\r
//! reset current working directory\r
getWorkingDirectory();\r
\r
-#ifdef __IRR_COMPILE_WITH_PAK_ARCHIVE_LOADER_\r
- ArchiveLoader.push_back(new CArchiveLoaderPAK(this));\r
-#endif\r
-\r
-#ifdef __IRR_COMPILE_WITH_NPK_ARCHIVE_LOADER_\r
- ArchiveLoader.push_back(new CArchiveLoaderNPK(this));\r
-#endif\r
-\r
-#ifdef __IRR_COMPILE_WITH_TAR_ARCHIVE_LOADER_\r
- ArchiveLoader.push_back(new CArchiveLoaderTAR(this));\r
-#endif\r
-\r
-#ifdef __IRR_COMPILE_WITH_WAD_ARCHIVE_LOADER_\r
- ArchiveLoader.push_back(new CArchiveLoaderWAD(this));\r
-#endif\r
-\r
-#ifdef __IRR_COMPILE_WITH_MOUNT_ARCHIVE_LOADER_\r
- ArchiveLoader.push_back(new CArchiveLoaderMount(this));\r
-#endif\r
-\r
-#ifdef __IRR_COMPILE_WITH_ZIP_ARCHIVE_LOADER_\r
ArchiveLoader.push_back(new CArchiveLoaderZIP(this));\r
-#endif\r
\r
}\r
\r
bool ret = false;\r
\r
// see if archive is already added\r
- if (changeArchivePassword(filename, password, retArchive))\r
- return true;\r
\r
s32 i;\r
\r
return ret;\r
}\r
\r
-// don't expose!\r
-bool CFileSystem::changeArchivePassword(const path& filename,\r
- const core::stringc& password,\r
- IFileArchive** archive)\r
-{\r
- for (s32 idx = 0; idx < (s32)FileArchives.size(); ++idx)\r
- {\r
- // TODO: This should go into a path normalization method\r
- // We need to check for directory names with trailing slash and without\r
- const path absPath = getAbsolutePath(filename);\r
- const path arcPath = FileArchives[idx]->getFileList()->getPath();\r
- if ((absPath == arcPath) || ((absPath+_IRR_TEXT("/")) == arcPath))\r
- {\r
- if (password.size())\r
- FileArchives[idx]->Password=password;\r
- if (archive)\r
- *archive = FileArchives[idx];\r
- return true;\r
- }\r
- }\r
-\r
- return false;\r
-}\r
\r
bool CFileSystem::addFileArchive(IReadFile* file, bool ignoreCase,\r
bool ignorePaths, E_FILE_ARCHIVE_TYPE archiveType,\r
\r
if (file)\r
{\r
- if (changeArchivePassword(file->getFileName(), password, retArchive))\r
- return true;\r
-\r
IFileArchive* archive = 0;\r
s32 i;\r
\r
{\r
#if defined(_IRR_WINDOWS_API_)\r
fschar_t tmp[_MAX_PATH];\r
- #if defined(_IRR_WCHAR_FILESYSTEM )\r
- _wgetcwd(tmp, _MAX_PATH);\r
- WorkingDirectory[FILESYSTEM_NATIVE] = tmp;\r
- WorkingDirectory[FILESYSTEM_NATIVE].replace(L'\\', L'/');\r
- #else\r
_getcwd(tmp, _MAX_PATH);\r
WorkingDirectory[FILESYSTEM_NATIVE] = tmp;\r
WorkingDirectory[FILESYSTEM_NATIVE].replace('\\', '/');\r
- #endif\r
#endif\r
\r
#if (defined(_IRR_POSIX_API_) || defined(_IRR_OSX_PLATFORM_))\r
// so try it until the call was successful\r
// Note that neither the first nor the second parameter may be 0 according to POSIX\r
\r
- #if defined(_IRR_WCHAR_FILESYSTEM )\r
- u32 pathSize=256;\r
- wchar_t *tmpPath = new wchar_t[pathSize];\r
- while ((pathSize < (1<<16)) && !(wgetcwd(tmpPath,pathSize)))\r
- {\r
- delete [] tmpPath;\r
- pathSize *= 2;\r
- tmpPath = new char[pathSize];\r
- }\r
- if (tmpPath)\r
- {\r
- WorkingDirectory[FILESYSTEM_NATIVE] = tmpPath;\r
- delete [] tmpPath;\r
- }\r
- #else\r
u32 pathSize=256;\r
char *tmpPath = new char[pathSize];\r
while ((pathSize < (1<<16)) && !(getcwd(tmpPath,pathSize)))\r
WorkingDirectory[FILESYSTEM_NATIVE] = tmpPath;\r
delete [] tmpPath;\r
}\r
- #endif\r
#endif\r
\r
WorkingDirectory[type].validate();\r
WorkingDirectory[FILESYSTEM_NATIVE] = newDirectory;\r
\r
#if defined(_MSC_VER)\r
- #if defined(_IRR_WCHAR_FILESYSTEM)\r
- success = (_wchdir(newDirectory.c_str()) == 0);\r
- #else\r
success = (_chdir(newDirectory.c_str()) == 0);\r
- #endif\r
#else\r
- #if defined(_IRR_WCHAR_FILESYSTEM)\r
- success = (_wchdir(newDirectory.c_str()) == 0);\r
- #else\r
success = (chdir(newDirectory.c_str()) == 0);\r
- #endif\r
#endif\r
}\r
\r
#if defined(_IRR_WINDOWS_API_)\r
fschar_t *p=0;\r
fschar_t fpath[_MAX_PATH];\r
- #if defined(_IRR_WCHAR_FILESYSTEM )\r
- p = _wfullpath(fpath, filename.c_str(), _MAX_PATH);\r
- core::stringw tmp(p);\r
- tmp.replace(L'\\', L'/');\r
- #else\r
p = _fullpath(fpath, filename.c_str(), _MAX_PATH);\r
core::stringc tmp(p);\r
tmp.replace('\\', '/');\r
- #endif\r
return tmp;\r
#elif (defined(_IRR_POSIX_API_) || defined(_IRR_OSX_PLATFORM_))\r
c8* p=0;\r
io::path path1, file, ext;\r
core::splitFilename(getAbsolutePath(filename), &path1, &file, &ext);\r
io::path path2(getAbsolutePath(directory));\r
- core::list<io::path> list1, list2;\r
+ std::list<io::path> list1, list2;\r
path1.split(list1, _IRR_TEXT("/\\"), 2);\r
path2.split(list2, _IRR_TEXT("/\\"), 2);\r
- u32 i=0;\r
- core::list<io::path>::ConstIterator it1,it2;\r
+ std::list<io::path>::const_iterator it1,it2;\r
it1=list1.begin();\r
it2=list2.begin();\r
\r
#endif\r
\r
\r
- for (; i<list1.size() && i<list2.size()\r
+ for (; it1 != list1.end() && it2 != list2.end()\r
#if defined (_IRR_WINDOWS_API_)\r
&& (io::path(*it1).make_lower()==io::path(*it2).make_lower())\r
#else\r
&& (*it1==*it2)\r
#endif\r
- ; ++i)\r
+ ;)\r
{\r
++it1;\r
++it2;\r
}\r
path1=_IRR_TEXT("");\r
- for (; i<list2.size(); ++i)\r
+ for (; it2 != list2.end(); ++it2)\r
path1 += _IRR_TEXT("../");\r
while (it1 != list1.end())\r
{\r
// --------------------------------------------\r
//! Windows version\r
#ifdef _IRR_WINDOWS_API_\r
- #if !defined ( _WIN32_WCE )\r
\r
r = new CFileList(Path, true, false);\r
\r
\r
_findclose( hFile );\r
}\r
- #endif\r
\r
- //TODO add drives\r
- //entry.Name = "E:\\";\r
- //entry.isDirectory = true;\r
- //Files.push_back(entry);\r
#endif\r
\r
// --------------------------------------------\r
return true;\r
\r
#if defined(_MSC_VER)\r
- #if defined(_IRR_WCHAR_FILESYSTEM)\r
- return (_waccess(filename.c_str(), 0) != -1);\r
- #else\r
return (_access(filename.c_str(), 0) != -1);\r
- #endif\r
#elif defined(F_OK)\r
- #if defined(_IRR_WCHAR_FILESYSTEM)\r
- return (_waccess(filename.c_str(), F_OK) != -1);\r
- #else\r
return (access(filename.c_str(), F_OK) != -1);\r
- #endif\r
#else\r
return (access(filename.c_str(), 0) != -1);\r
#endif\r
}\r
\r
\r
-//! Creates a new empty collection of attributes, usable for serialization and more.\r
-IAttributes* CFileSystem::createEmptyAttributes(video::IVideoDriver* driver)\r
-{\r
- return new CAttributes(driver);\r
-}\r
-\r
-\r
} // end namespace irr\r
} // end namespace io\r