FileSystem.cpp 19 KB

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