FileSystem.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  1. //
  2. // Urho3D Engine
  3. // Copyright (c) 2008-2012 Lasse Oorni
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to deal
  7. // in the Software without restriction, including without limitation the rights
  8. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. // copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. // THE SOFTWARE.
  22. //
  23. #include "Precompiled.h"
  24. #include "ArrayPtr.h"
  25. #include "Context.h"
  26. #include "File.h"
  27. #include "FileSystem.h"
  28. #include "Log.h"
  29. #include <cstdio>
  30. #include <cstring>
  31. #ifdef WIN32
  32. #ifndef _MSC_VER
  33. #define _WIN32_IE 0x400
  34. #endif
  35. #include <windows.h>
  36. #include <shellapi.h>
  37. #include <direct.h>
  38. #include <shlobj.h>
  39. #else
  40. #include <dirent.h>
  41. #include <errno.h>
  42. #include <unistd.h>
  43. #include <sys/stat.h>
  44. #include <sys/wait.h>
  45. #define MAX_PATH 256
  46. #endif
  47. #if defined(__APPLE__)
  48. #include <mach-o/dyld.h>
  49. #endif
  50. #ifdef ANDROID
  51. extern "C" const char* SDL_Android_GetFilesDir();
  52. #endif
  53. #ifdef IOS
  54. extern "C" const char* SDL_IOS_GetResourceDir();
  55. #endif
  56. #include "DebugNew.h"
  57. namespace Urho3D
  58. {
  59. OBJECTTYPESTATIC(FileSystem);
  60. FileSystem::FileSystem(Context* context) :
  61. Object(context)
  62. {
  63. }
  64. FileSystem::~FileSystem()
  65. {
  66. }
  67. bool FileSystem::SetCurrentDir(const String& pathName)
  68. {
  69. if (!CheckAccess(pathName))
  70. {
  71. LOGERROR("Access denied to " + pathName);
  72. return false;
  73. }
  74. #ifdef WIN32
  75. if (SetCurrentDirectoryW(GetWideNativePath(pathName).CString()) == FALSE)
  76. {
  77. LOGERROR("Failed to change directory to " + pathName);
  78. return false;
  79. }
  80. #else
  81. if (chdir(GetNativePath(pathName).CString()) != 0)
  82. {
  83. LOGERROR("Failed to change directory to " + pathName);
  84. return false;
  85. }
  86. #endif
  87. return true;
  88. }
  89. bool FileSystem::CreateDir(const String& pathName)
  90. {
  91. if (!CheckAccess(pathName))
  92. {
  93. LOGERROR("Access denied to " + pathName);
  94. return false;
  95. }
  96. #ifdef WIN32
  97. bool success = (CreateDirectoryW(GetWideNativePath(RemoveTrailingSlash(pathName)).CString(), 0) == TRUE) ||
  98. (GetLastError() == ERROR_ALREADY_EXISTS);
  99. #else
  100. bool success = mkdir(GetNativePath(RemoveTrailingSlash(pathName)).CString(), S_IRWXU) == 0 || errno == EEXIST;
  101. #endif
  102. if (success)
  103. LOGDEBUG("Created directory " + pathName);
  104. else
  105. LOGERROR("Failed to create directory " + pathName);
  106. return success;
  107. }
  108. int FileSystem::SystemCommand(const String& commandLine)
  109. {
  110. if (allowedPaths_.Empty())
  111. return system(commandLine.CString());
  112. else
  113. {
  114. LOGERROR("Executing an external command is not allowed");
  115. return -1;
  116. }
  117. }
  118. int FileSystem::SystemRun(const String& fileName, const Vector<String>& arguments)
  119. {
  120. if (allowedPaths_.Empty())
  121. {
  122. String fixedFileName = GetNativePath(fileName);
  123. #ifdef WIN32
  124. // Add .exe extension if no extension defined
  125. if (GetExtension(fixedFileName).Empty())
  126. fixedFileName += ".exe";
  127. String commandLine = "\"" + fixedFileName + "\"";
  128. for (unsigned i = 0; i < arguments.Size(); ++i)
  129. commandLine += " " + arguments[i];
  130. STARTUPINFOW startupInfo;
  131. PROCESS_INFORMATION processInfo;
  132. memset(&startupInfo, 0, sizeof startupInfo);
  133. memset(&processInfo, 0, sizeof processInfo);
  134. WString commandLineW(commandLine);
  135. if (!CreateProcessW(NULL, (wchar_t*)commandLineW.CString(), 0, 0, 0, CREATE_NO_WINDOW, 0, 0, &startupInfo, &processInfo))
  136. {
  137. LOGERROR("Failed to execute command " + commandLine);
  138. return -1;
  139. }
  140. WaitForSingleObject(processInfo.hProcess, INFINITE);
  141. DWORD exitCode;
  142. GetExitCodeProcess(processInfo.hProcess, &exitCode);
  143. CloseHandle(processInfo.hProcess);
  144. CloseHandle(processInfo.hThread);
  145. return exitCode;
  146. #else
  147. pid_t pid = fork();
  148. if (!pid)
  149. {
  150. PODVector<const char*> argPtrs;
  151. argPtrs.Push(fixedFileName.CString());
  152. for (unsigned i = 0; i < arguments.Size(); ++i)
  153. argPtrs.Push(arguments[i].CString());
  154. argPtrs.Push(0);
  155. execvp(argPtrs[0], (char**)&argPtrs[0]);
  156. return -1; // Return -1 if we could not spawn the process
  157. }
  158. else if (pid > 0)
  159. {
  160. int exitCode;
  161. wait(&exitCode);
  162. return exitCode ? 1 : 0;
  163. }
  164. else
  165. {
  166. LOGERROR("Failed to fork");
  167. return -1;
  168. }
  169. #endif
  170. }
  171. else
  172. {
  173. LOGERROR("Executing an external command is not allowed");
  174. return -1;
  175. }
  176. }
  177. bool FileSystem::SystemOpen(const String& fileName, const String& mode)
  178. {
  179. if (allowedPaths_.Empty())
  180. {
  181. if (!FileExists(fileName) && !DirExists(fileName))
  182. {
  183. LOGERROR("File or directory " + fileName + " not found");
  184. return false;
  185. }
  186. #ifdef WIN32
  187. bool success = (int)ShellExecuteW(0, !mode.Empty() ? WString(mode).CString() : 0,
  188. GetWideNativePath(fileName).CString(), 0, 0, SW_SHOW) > 32;
  189. if (!success)
  190. LOGERROR("Failed to open " + fileName + " externally");
  191. return success;
  192. #elif defined(__APPLE__)
  193. Vector<String> arguments;
  194. arguments.Push(fileName);
  195. return SystemRun("open", arguments) == 0;
  196. #else
  197. /// \todo Implement on Unix-like systems
  198. LOGERROR("SystemOpen not implemented");
  199. return false;
  200. #endif
  201. }
  202. else
  203. {
  204. LOGERROR("Opening a file externally is not allowed");
  205. return false;
  206. }
  207. }
  208. bool FileSystem::Copy(const String& srcFileName, const String& destFileName)
  209. {
  210. if (!CheckAccess(GetPath(srcFileName)))
  211. {
  212. LOGERROR("Access denied to " + srcFileName);
  213. return false;
  214. }
  215. if (!CheckAccess(GetPath(destFileName)))
  216. {
  217. LOGERROR("Access denied to " + destFileName);
  218. return false;
  219. }
  220. SharedPtr<File> srcFile(new File(context_, srcFileName, FILE_READ));
  221. SharedPtr<File> destFile(new File(context_, destFileName, FILE_WRITE));
  222. if (!srcFile->IsOpen() || !destFile->IsOpen())
  223. return false;
  224. unsigned fileSize = srcFile->GetSize();
  225. SharedArrayPtr<unsigned char> buffer(new unsigned char[fileSize]);
  226. unsigned bytesRead = srcFile->Read(buffer.Get(), fileSize);
  227. unsigned bytesWritten = destFile->Write(buffer.Get(), fileSize);
  228. return bytesRead == fileSize && bytesWritten == fileSize;
  229. }
  230. bool FileSystem::Rename(const String& srcFileName, const String& destFileName)
  231. {
  232. if (!CheckAccess(GetPath(srcFileName)))
  233. {
  234. LOGERROR("Access denied to " + srcFileName);
  235. return false;
  236. }
  237. if (!CheckAccess(GetPath(destFileName)))
  238. {
  239. LOGERROR("Access denied to " + destFileName);
  240. return false;
  241. }
  242. #ifdef WIN32
  243. return MoveFileW(GetWideNativePath(srcFileName).CString(), GetWideNativePath(destFileName).CString()) != 0;
  244. #else
  245. return rename(GetNativePath(srcFileName).CString(), GetNativePath(destFileName).CString()) == 0;
  246. #endif
  247. }
  248. bool FileSystem::Delete(const String& fileName)
  249. {
  250. if (!CheckAccess(GetPath(fileName)))
  251. {
  252. LOGERROR("Access denied to " + fileName);
  253. return false;
  254. }
  255. #ifdef WIN32
  256. return DeleteFileW(GetWideNativePath(fileName).CString()) != 0;
  257. #else
  258. return remove(GetNativePath(fileName).CString()) == 0;
  259. #endif
  260. }
  261. String FileSystem::GetCurrentDir() const
  262. {
  263. #ifdef WIN32
  264. wchar_t path[MAX_PATH];
  265. path[0] = 0;
  266. GetCurrentDirectoryW(MAX_PATH, path);
  267. return AddTrailingSlash(String(path));
  268. #else
  269. char path[MAX_PATH];
  270. path[0] = 0;
  271. getcwd(path, MAX_PATH);
  272. return AddTrailingSlash(String(path));
  273. #endif
  274. }
  275. bool FileSystem::CheckAccess(const String& pathName) const
  276. {
  277. String fixedPath = AddTrailingSlash(pathName);
  278. // If no allowed directories defined, succeed always
  279. if (allowedPaths_.Empty())
  280. return true;
  281. // If there is any attempt to go to a parent directory, disallow
  282. if (fixedPath.Contains(".."))
  283. return false;
  284. // Check if the path is a partial match of any of the allowed directories
  285. for (HashSet<String>::ConstIterator i = allowedPaths_.Begin(); i != allowedPaths_.End(); ++i)
  286. {
  287. if (fixedPath.Find(*i) == 0)
  288. return true;
  289. }
  290. // Not found, so disallow
  291. return false;
  292. }
  293. unsigned FileSystem::GetLastModifiedTime(const String& fileName) const
  294. {
  295. if (fileName.Empty() || !CheckAccess(fileName))
  296. return 0;
  297. #ifdef WIN32
  298. WIN32_FILE_ATTRIBUTE_DATA fileAttrData;
  299. memset(&fileAttrData, 0, sizeof fileAttrData);
  300. if (GetFileAttributesExW(WString(fileName).CString(), GetFileExInfoStandard, &fileAttrData))
  301. {
  302. ULARGE_INTEGER ull;
  303. ull.LowPart = fileAttrData.ftLastWriteTime.dwLowDateTime;
  304. ull.HighPart = fileAttrData.ftLastWriteTime.dwHighDateTime;
  305. return (unsigned)(ull.QuadPart / 10000000ULL - 11644473600ULL);
  306. }
  307. else
  308. return 0;
  309. #else
  310. struct stat st;
  311. if (!stat(fileName.CString(), &st))
  312. return (unsigned)st.st_mtime;
  313. else
  314. return 0;
  315. #endif
  316. }
  317. bool FileSystem::FileExists(const String& fileName) const
  318. {
  319. if (!CheckAccess(GetPath(fileName)))
  320. return false;
  321. String fixedName = GetNativePath(RemoveTrailingSlash(fileName));
  322. #ifdef ANDROID
  323. if (fixedName.StartsWith("/apk/"))
  324. {
  325. SDL_RWops* rwOps = SDL_RWFromFile(fileName.Substring(5).CString(), "rb");
  326. if (rwOps)
  327. {
  328. SDL_RWclose(rwOps);
  329. return true;
  330. }
  331. else
  332. return false;
  333. }
  334. #endif
  335. #ifdef WIN32
  336. DWORD attributes = GetFileAttributesW(WString(fixedName).CString());
  337. if (attributes == INVALID_FILE_ATTRIBUTES || attributes & FILE_ATTRIBUTE_DIRECTORY)
  338. return false;
  339. #else
  340. struct stat st;
  341. if (stat(fixedName.CString(), &st) || st.st_mode & S_IFDIR)
  342. return false;
  343. #endif
  344. return true;
  345. }
  346. bool FileSystem::DirExists(const String& pathName) const
  347. {
  348. if (!CheckAccess(pathName))
  349. return false;
  350. #ifndef WIN32
  351. // Always return true for the root directory
  352. if (pathName == "/")
  353. return true;
  354. #endif
  355. String fixedName = GetNativePath(RemoveTrailingSlash(pathName));
  356. #ifdef ANDROID
  357. /// \todo Actually check for existence, now true is always returned for directories within the APK
  358. if (fixedName.StartsWith("/apk/"))
  359. return true;
  360. #endif
  361. #ifdef WIN32
  362. DWORD attributes = GetFileAttributesW(WString(fixedName).CString());
  363. if (attributes == INVALID_FILE_ATTRIBUTES || !(attributes & FILE_ATTRIBUTE_DIRECTORY))
  364. return false;
  365. #else
  366. struct stat st;
  367. if (stat(fixedName.CString(), &st) || !(st.st_mode & S_IFDIR))
  368. return false;
  369. #endif
  370. return true;
  371. }
  372. void FileSystem::ScanDir(Vector<String>& result, const String& pathName, const String& filter, unsigned flags, bool recursive) const
  373. {
  374. result.Clear();
  375. if (CheckAccess(pathName))
  376. {
  377. String initialPath = AddTrailingSlash(pathName);
  378. ScanDirInternal(result, initialPath, initialPath, filter, flags, recursive);
  379. }
  380. }
  381. String FileSystem::GetProgramDir() const
  382. {
  383. #if defined(ANDROID)
  384. // This is an internal directory specifier pointing to the assets in the .apk
  385. // Files from this directory will be opened using special handling
  386. return "/apk/";
  387. #elif defined(IOS)
  388. return AddTrailingSlash(SDL_IOS_GetResourceDir());
  389. #elif defined(WIN32)
  390. wchar_t exeName[MAX_PATH];
  391. exeName[0] = 0;
  392. GetModuleFileNameW(0, exeName, MAX_PATH);
  393. return GetPath(String(exeName));
  394. #elif defined(__APPLE__)
  395. char exeName[MAX_PATH];
  396. memset(exeName, 0, MAX_PATH);
  397. unsigned size = MAX_PATH;
  398. _NSGetExecutablePath(exeName, &size);
  399. return GetPath(String(exeName));
  400. #elif defined(__linux__)
  401. char exeName[MAX_PATH];
  402. memset(exeName, 0, MAX_PATH);
  403. pid_t pid = getpid();
  404. String link = "/proc/" + String(pid) + "/exe";
  405. readlink(link.CString(), exeName, MAX_PATH);
  406. return GetPath(String(exeName));
  407. #else
  408. return String();
  409. #endif
  410. }
  411. String FileSystem::GetUserDocumentsDir() const
  412. {
  413. #if defined(ANDROID)
  414. return AddTrailingSlash(SDL_Android_GetFilesDir());
  415. #elif defined(IOS)
  416. return AddTrailingSlash(SDL_IOS_GetResourceDir());
  417. #elif defined(WIN32)
  418. wchar_t pathName[MAX_PATH];
  419. pathName[0] = 0;
  420. SHGetSpecialFolderPathW(0, pathName, CSIDL_PERSONAL, 0);
  421. return AddTrailingSlash(String(pathName));
  422. #else
  423. char pathName[MAX_PATH];
  424. pathName[0] = 0;
  425. strcpy(pathName, getenv("HOME"));
  426. return AddTrailingSlash(String(pathName));
  427. #endif
  428. }
  429. void FileSystem::RegisterPath(const String& pathName)
  430. {
  431. if (pathName.Empty())
  432. return;
  433. allowedPaths_.Insert(AddTrailingSlash(pathName));
  434. }
  435. void FileSystem::ScanDirInternal(Vector<String>& result, String path, const String& startPath,
  436. const String& filter, unsigned flags, bool recursive) const
  437. {
  438. path = AddTrailingSlash(path);
  439. String deltaPath;
  440. if (path.Length() > startPath.Length())
  441. deltaPath = path.Substring(startPath.Length());
  442. #ifdef WIN32
  443. String pathAndFilter = GetNativePath(path + filter);
  444. WIN32_FIND_DATAW info;
  445. HANDLE handle = FindFirstFileW(WString(pathAndFilter).CString(), &info);
  446. if (handle != INVALID_HANDLE_VALUE)
  447. {
  448. do
  449. {
  450. String fileName(info.cFileName);
  451. if (!fileName.Empty())
  452. {
  453. if (info.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN && !(flags & SCAN_HIDDEN))
  454. continue;
  455. if (info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
  456. {
  457. if (flags & SCAN_DIRS)
  458. result.Push(deltaPath + fileName);
  459. if (recursive && fileName != "." && fileName != "..")
  460. ScanDirInternal(result, path + fileName, startPath, filter, flags, recursive);
  461. }
  462. else if (flags & SCAN_FILES)
  463. result.Push(deltaPath + fileName);
  464. }
  465. }
  466. while (FindNextFileW(handle, &info));
  467. FindClose(handle);
  468. }
  469. #else
  470. String filterExtension = filter.Substring(filter.Find('.'));
  471. if (filterExtension.Contains('*'))
  472. filterExtension.Clear();
  473. DIR *dir;
  474. struct dirent *de;
  475. struct stat st;
  476. dir = opendir(GetNativePath(path).CString());
  477. if (dir)
  478. {
  479. while ((de = readdir(dir)))
  480. {
  481. /// \todo Filename may be unnormalized Unicode on Mac OS X. Re-normalize as necessary
  482. String fileName(de->d_name);
  483. bool normalEntry = fileName != "." && fileName != "..";
  484. if (normalEntry && !(flags & SCAN_HIDDEN) && fileName.StartsWith("."))
  485. continue;
  486. String pathAndName = path + fileName;
  487. if (!stat(pathAndName.CString(), &st))
  488. {
  489. if (st.st_mode & S_IFDIR)
  490. {
  491. if (flags & SCAN_DIRS)
  492. result.Push(deltaPath + fileName);
  493. if (recursive && normalEntry)
  494. ScanDirInternal(result, path + fileName, startPath, filter, flags, recursive);
  495. }
  496. else if (flags & SCAN_FILES)
  497. {
  498. if (filterExtension.Empty() || fileName.EndsWith(filterExtension))
  499. result.Push(deltaPath + fileName);
  500. }
  501. }
  502. }
  503. closedir(dir);
  504. }
  505. #endif
  506. }
  507. void SplitPath(const String& fullPath, String& pathName, String& fileName, String& extension)
  508. {
  509. String fullPathCopy = GetInternalPath(fullPath);
  510. unsigned extPos = fullPathCopy.FindLast('.');
  511. unsigned pathPos = fullPathCopy.FindLast('/');
  512. if (extPos != String::NPOS && (pathPos == String::NPOS || extPos > pathPos))
  513. {
  514. extension = fullPathCopy.Substring(extPos).ToLower();
  515. fullPathCopy = fullPathCopy.Substring(0, extPos);
  516. }
  517. else
  518. extension.Clear();
  519. pathPos = fullPathCopy.FindLast('/');
  520. if (pathPos != String::NPOS)
  521. {
  522. fileName = fullPathCopy.Substring(pathPos + 1);
  523. pathName = fullPathCopy.Substring(0, pathPos + 1);
  524. }
  525. else
  526. {
  527. fileName = fullPathCopy;
  528. pathName.Clear();
  529. }
  530. }
  531. String GetPath(const String& fullPath)
  532. {
  533. String path, file, extension;
  534. SplitPath(fullPath, path, file, extension);
  535. return path;
  536. }
  537. String GetFileName(const String& fullPath)
  538. {
  539. String path, file, extension;
  540. SplitPath(fullPath, path, file, extension);
  541. return file;
  542. }
  543. String GetExtension(const String& fullPath)
  544. {
  545. String path, file, extension;
  546. SplitPath(fullPath, path, file, extension);
  547. return extension;
  548. }
  549. String GetFileNameAndExtension(const String& fileName)
  550. {
  551. String path, file, extension;
  552. SplitPath(fileName, path, file, extension);
  553. return file + extension;
  554. }
  555. String ReplaceExtension(const String& fullPath, const String& newExtension)
  556. {
  557. String path, file, extension;
  558. SplitPath(fullPath, path, file, extension);
  559. return path + file + newExtension;
  560. }
  561. String AddTrailingSlash(const String& pathName)
  562. {
  563. String ret = pathName;
  564. ret.Replace('\\', '/');
  565. if (!ret.Empty() && ret.Back() != '/')
  566. ret += '/';
  567. return ret;
  568. }
  569. String RemoveTrailingSlash(const String& pathName)
  570. {
  571. String ret = pathName;
  572. ret.Replace('\\', '/');
  573. if (!ret.Empty() && ret.Back() == '/')
  574. ret.Resize(ret.Length() - 1);
  575. return ret;
  576. }
  577. String GetParentPath(const String& path)
  578. {
  579. unsigned pos = RemoveTrailingSlash(path).FindLast('/');
  580. if (pos != String::NPOS)
  581. return path.Substring(0, pos + 1);
  582. else
  583. return String();
  584. }
  585. String GetInternalPath(const String& pathName)
  586. {
  587. return pathName.Replaced('\\', '/');
  588. }
  589. String GetNativePath(const String& pathName)
  590. {
  591. #ifdef WIN32
  592. return pathName.Replaced('/', '\\');
  593. #else
  594. return pathName;
  595. #endif
  596. }
  597. WString GetWideNativePath(const String& pathName)
  598. {
  599. #ifdef WIN32
  600. return WString(pathName.Replaced('/', '\\'));
  601. #else
  602. return WString(pathName);
  603. #endif
  604. }
  605. }