MSFileSystemImpl.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  1. //===- llvm/Support/Windows/MSFileSystemImpl.cpp DXComplier Impl *- C++ -*-===//
  2. ///////////////////////////////////////////////////////////////////////////////
  3. // //
  4. // MSFileSystemImpl.cpp //
  5. // Copyright (C) Microsoft Corporation. All rights reserved. //
  6. // This file is distributed under the University of Illinois Open Source //
  7. // License. See LICENSE.TXT for details. //
  8. // //
  9. // This file implements the DXCompiler specific implementation of the Path API.//
  10. // //
  11. ///////////////////////////////////////////////////////////////////////////////
  12. #include <fcntl.h>
  13. #ifdef _WIN32
  14. #include <io.h>
  15. #else
  16. #include <sys/types.h>
  17. #include <unistd.h>
  18. #endif
  19. #include <sys/stat.h>
  20. #include <sys/types.h>
  21. #include <stdint.h>
  22. #include <errno.h>
  23. #include <new>
  24. #include "dxc/Support/WinIncludes.h"
  25. #include "dxc/Support/WinAdapter.h"
  26. #include "llvm/Support/MSFileSystem.h"
  27. ///////////////////////////////////////////////////////////////////////////////////////////////////
  28. // Externally visible functions.
  29. HRESULT CreateMSFileSystemForDisk(_COM_Outptr_ ::llvm::sys::fs::MSFileSystem** pResult) throw();
  30. ///////////////////////////////////////////////////////////////////////////////////////////////////
  31. // Win32-and-CRT-based MSFileSystem implementation with direct filesystem access.
  32. namespace llvm {
  33. namespace sys {
  34. namespace fs {
  35. class MSFileSystemForDisk : public MSFileSystem
  36. {
  37. public:
  38. unsigned _defaultAttributes;
  39. MSFileSystemForDisk();
  40. virtual BOOL FindNextFileW(_In_ HANDLE hFindFile, _Out_ LPWIN32_FIND_DATAW lpFindFileData) throw() override;
  41. virtual HANDLE FindFirstFileW(_In_ LPCWSTR lpFileName, _Out_ LPWIN32_FIND_DATAW lpFindFileData) throw() override;
  42. virtual void FindClose(HANDLE findHandle) throw() override;
  43. virtual HANDLE CreateFileW(_In_ LPCWSTR lpFileName, _In_ DWORD dwDesiredAccess, _In_ DWORD dwShareMode, _In_ DWORD dwCreationDisposition, _In_ DWORD dwFlagsAndAttributes) throw() override;
  44. virtual BOOL SetFileTime(_In_ HANDLE hFile, _In_opt_ const FILETIME *lpCreationTime, _In_opt_ const FILETIME *lpLastAccessTime, _In_opt_ const FILETIME *lpLastWriteTime) throw() override;
  45. virtual BOOL GetFileInformationByHandle(_In_ HANDLE hFile, _Out_ LPBY_HANDLE_FILE_INFORMATION lpFileInformation) throw() override;
  46. virtual DWORD GetFileType(_In_ HANDLE hFile) throw() override;
  47. virtual BOOL CreateHardLinkW(_In_ LPCWSTR lpFileName, _In_ LPCWSTR lpExistingFileName) throw() override;
  48. virtual BOOL MoveFileExW(_In_ LPCWSTR lpExistingFileName, _In_opt_ LPCWSTR lpNewFileName, _In_ DWORD dwFlags) throw() override;
  49. virtual DWORD GetFileAttributesW(_In_ LPCWSTR lpFileName) throw() override;
  50. virtual BOOL CloseHandle(_In_ HANDLE hObject) throw() override;
  51. virtual BOOL DeleteFileW(_In_ LPCWSTR lpFileName) throw() override;
  52. virtual BOOL RemoveDirectoryW(_In_ LPCWSTR lpFileName) throw() override;
  53. virtual BOOL CreateDirectoryW(_In_ LPCWSTR lpPathName) throw() override;
  54. _Success_(return != 0 && return < nBufferLength)
  55. virtual DWORD GetCurrentDirectoryW(_In_ DWORD nBufferLength, _Out_writes_to_opt_(nBufferLength, return + 1) LPWSTR lpBuffer) throw() override;
  56. _Success_(return != 0 && return < nSize)
  57. virtual DWORD GetMainModuleFileNameW(__out_ecount_part(nSize, return + 1) LPWSTR lpFilename, DWORD nSize) throw() override;
  58. virtual DWORD GetTempPathW(DWORD nBufferLength, _Out_writes_to_opt_(nBufferLength, return + 1) LPWSTR lpBuffer) throw() override;
  59. virtual BOOLEAN CreateSymbolicLinkW(_In_ LPCWSTR lpSymlinkFileName, _In_ LPCWSTR lpTargetFileName, DWORD dwFlags) throw() override;
  60. virtual bool SupportsCreateSymbolicLink() throw() override;
  61. virtual BOOL ReadFile(_In_ HANDLE hFile, _Out_bytecap_(nNumberOfBytesToRead) LPVOID lpBuffer, _In_ DWORD nNumberOfBytesToRead, _Out_opt_ LPDWORD lpNumberOfBytesRead) throw() override;
  62. virtual HANDLE CreateFileMappingW(_In_ HANDLE hFile, _In_ DWORD flProtect, _In_ DWORD dwMaximumSizeHigh, _In_ DWORD dwMaximumSizeLow) throw() override;
  63. virtual LPVOID MapViewOfFile(_In_ HANDLE hFileMappingObject, _In_ DWORD dwDesiredAccess, _In_ DWORD dwFileOffsetHigh, _In_ DWORD dwFileOffsetLow, _In_ SIZE_T dwNumberOfBytesToMap) throw() override;
  64. virtual BOOL UnmapViewOfFile(_In_ LPCVOID lpBaseAddress) throw() override;
  65. // Console APIs.
  66. virtual bool FileDescriptorIsDisplayed(int fd) throw() override;
  67. virtual unsigned GetColumnCount(DWORD nStdHandle) throw() override;
  68. virtual unsigned GetConsoleOutputTextAttributes() throw() override;
  69. virtual void SetConsoleOutputTextAttributes(unsigned attributes) throw() override;
  70. virtual void ResetConsoleOutputTextAttributes() throw() override;
  71. // CRT APIs.
  72. virtual int open_osfhandle(intptr_t osfhandle, int flags) throw() override;
  73. virtual intptr_t get_osfhandle(int fd) throw() override;
  74. virtual int close(int fd) throw() override;
  75. virtual long lseek(int fd, long offset, int origin) throw() override;
  76. virtual int setmode(int fd, int mode) throw() override;
  77. virtual errno_t resize_file(_In_ LPCWSTR path, uint64_t size) throw() override;
  78. virtual int Read(int fd, _Out_bytecap_(count) void* buffer, unsigned int count) throw() override;
  79. virtual int Write(int fd, _In_bytecount_(count) const void* buffer, unsigned int count) throw() override;
  80. #ifndef _WIN32
  81. virtual int Open(const char *lpFileName, int flags, mode_t mode) throw() override;
  82. virtual int Stat(const char *lpFileName, struct stat *Status) throw() override;
  83. virtual int Fstat(int FD, struct stat *Status) throw() override;
  84. #endif
  85. };
  86. MSFileSystemForDisk::MSFileSystemForDisk()
  87. {
  88. #ifdef _WIN32
  89. _defaultAttributes = GetConsoleOutputTextAttributes();
  90. #endif
  91. }
  92. _Use_decl_annotations_
  93. BOOL MSFileSystemForDisk::FindNextFileW(HANDLE hFindFile, LPWIN32_FIND_DATAW lpFindFileData) throw()
  94. {
  95. #ifdef _WIN32
  96. return ::FindNextFileW(hFindFile, lpFindFileData);
  97. #else
  98. assert(false && "Not implemented for Unix");
  99. return false;
  100. #endif
  101. }
  102. _Use_decl_annotations_
  103. HANDLE MSFileSystemForDisk::FindFirstFileW(LPCWSTR lpFileName, LPWIN32_FIND_DATAW lpFindFileData) throw()
  104. {
  105. #ifdef _WIN32
  106. return ::FindFirstFileW(lpFileName, lpFindFileData);
  107. #else
  108. assert(false && "Not implemented for Unix");
  109. return nullptr;
  110. #endif
  111. }
  112. void MSFileSystemForDisk::FindClose(HANDLE findHandle) throw()
  113. {
  114. #ifdef _WIN32
  115. ::FindClose(findHandle);
  116. #else
  117. assert(false && "Not implemented for Unix");
  118. #endif
  119. }
  120. _Use_decl_annotations_
  121. HANDLE MSFileSystemForDisk::CreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes) throw()
  122. {
  123. #ifdef _WIN32
  124. return ::CreateFileW(lpFileName, dwDesiredAccess, dwShareMode, nullptr, dwCreationDisposition, dwFlagsAndAttributes, nullptr);
  125. #else
  126. assert(false && "Not implemented for Unix");
  127. return nullptr;
  128. #endif
  129. }
  130. _Use_decl_annotations_
  131. BOOL MSFileSystemForDisk::SetFileTime(HANDLE hFile, _In_opt_ const FILETIME *lpCreationTime, _In_opt_ const FILETIME *lpLastAccessTime, _In_opt_ const FILETIME *lpLastWriteTime) throw()
  132. {
  133. #ifdef _WIN32
  134. return ::SetFileTime(hFile, lpCreationTime, lpLastAccessTime, lpLastWriteTime);
  135. #else
  136. assert(false && "Not implemented for Unix");
  137. return false;
  138. #endif
  139. }
  140. _Use_decl_annotations_
  141. BOOL MSFileSystemForDisk::GetFileInformationByHandle(HANDLE hFile, LPBY_HANDLE_FILE_INFORMATION lpFileInformation) throw()
  142. {
  143. #ifdef _WIN32
  144. return ::GetFileInformationByHandle(hFile, lpFileInformation);
  145. #else
  146. assert(false && "Not implemented for Unix");
  147. return false;
  148. #endif
  149. }
  150. _Use_decl_annotations_
  151. DWORD MSFileSystemForDisk::GetFileType(HANDLE hFile) throw()
  152. {
  153. #ifdef _WIN32
  154. return ::GetFileType(hFile);
  155. #else
  156. assert(false && "Not implemented for Unix");
  157. return 0;
  158. #endif
  159. }
  160. _Use_decl_annotations_
  161. BOOL MSFileSystemForDisk::CreateHardLinkW(LPCWSTR lpFileName, LPCWSTR lpExistingFileName) throw()
  162. {
  163. #ifdef _WIN32
  164. return ::CreateHardLinkW(lpFileName, lpExistingFileName, nullptr);
  165. #else
  166. assert(false && "Not implemented for Unix");
  167. return false;
  168. #endif
  169. }
  170. _Use_decl_annotations_
  171. BOOL MSFileSystemForDisk::MoveFileExW(LPCWSTR lpExistingFileName, LPCWSTR lpNewFileName, DWORD dwFlags) throw()
  172. {
  173. #ifdef _WIN32
  174. return ::MoveFileExW(lpExistingFileName, lpNewFileName, dwFlags);
  175. #else
  176. assert(false && "Not implemented for Unix");
  177. return false;
  178. #endif
  179. }
  180. _Use_decl_annotations_
  181. DWORD MSFileSystemForDisk::GetFileAttributesW(LPCWSTR lpFileName) throw()
  182. {
  183. #ifdef _WIN32
  184. return ::GetFileAttributesW(lpFileName);
  185. #else
  186. assert(false && "Not implemented for Unix");
  187. return 0;
  188. #endif
  189. }
  190. _Use_decl_annotations_
  191. BOOL MSFileSystemForDisk::CloseHandle(HANDLE hObject) throw()
  192. {
  193. #ifdef _WIN32
  194. return ::CloseHandle(hObject);
  195. #else
  196. assert(false && "Not implemented for Unix");
  197. return false;
  198. #endif
  199. }
  200. _Use_decl_annotations_
  201. BOOL MSFileSystemForDisk::DeleteFileW(LPCWSTR lpFileName) throw()
  202. {
  203. #ifdef _WIN32
  204. return ::DeleteFileW(lpFileName);
  205. #else
  206. assert(false && "Not implemented for Unix");
  207. return false;
  208. #endif
  209. }
  210. _Use_decl_annotations_
  211. BOOL MSFileSystemForDisk::RemoveDirectoryW(LPCWSTR lpFileName) throw()
  212. {
  213. #ifdef _WIN32
  214. return ::RemoveDirectoryW(lpFileName);
  215. #else
  216. assert(false && "Not implemented for Unix");
  217. return false;
  218. #endif
  219. }
  220. _Use_decl_annotations_
  221. BOOL MSFileSystemForDisk::CreateDirectoryW(LPCWSTR lpPathName) throw()
  222. {
  223. #ifdef _WIN32
  224. return ::CreateDirectoryW(lpPathName, nullptr);
  225. #else
  226. assert(false && "Not implemented for Unix");
  227. return false;
  228. #endif
  229. }
  230. _Use_decl_annotations_
  231. DWORD MSFileSystemForDisk::GetCurrentDirectoryW(DWORD nBufferLength, LPWSTR lpBuffer) throw()
  232. {
  233. #ifdef _WIN32
  234. return ::GetCurrentDirectoryW(nBufferLength, lpBuffer);
  235. #else
  236. assert(false && "Not implemented for Unix");
  237. return 0;
  238. #endif
  239. }
  240. _Use_decl_annotations_
  241. DWORD MSFileSystemForDisk::GetMainModuleFileNameW(LPWSTR lpFilename, DWORD nSize) throw()
  242. {
  243. #ifdef _WIN32
  244. // Add some code to ensure that the result is null terminated.
  245. if (nSize <= 1)
  246. {
  247. ::SetLastError(ERROR_INSUFFICIENT_BUFFER);
  248. return 0;
  249. }
  250. DWORD result = ::GetModuleFileNameW(nullptr, lpFilename, nSize - 1);
  251. if (result == 0) return result;
  252. lpFilename[result] = L'\0';
  253. return result;
  254. #else
  255. assert(false && "Not implemented for Unix");
  256. return 0;
  257. #endif
  258. }
  259. _Use_decl_annotations_
  260. DWORD MSFileSystemForDisk::GetTempPathW(DWORD nBufferLength, LPWSTR lpBuffer) throw()
  261. {
  262. #ifdef _WIN32
  263. return ::GetTempPathW(nBufferLength, lpBuffer);
  264. #else
  265. assert(false && "Not implemented for Unix");
  266. return 0;
  267. #endif
  268. }
  269. #ifdef _WIN32
  270. namespace {
  271. typedef BOOLEAN(WINAPI *PtrCreateSymbolicLinkW)(
  272. /*__in*/ LPCWSTR lpSymlinkFileName,
  273. /*__in*/ LPCWSTR lpTargetFileName,
  274. /*__in*/ DWORD dwFlags);
  275. PtrCreateSymbolicLinkW create_symbolic_link_api =
  276. PtrCreateSymbolicLinkW(::GetProcAddress(
  277. ::GetModuleHandleW(L"Kernel32.dll"), "CreateSymbolicLinkW"));
  278. }
  279. #endif
  280. _Use_decl_annotations_
  281. BOOLEAN MSFileSystemForDisk::CreateSymbolicLinkW(LPCWSTR lpSymlinkFileName, LPCWSTR lpTargetFileName, DWORD dwFlags) throw()
  282. {
  283. #ifdef _WIN32
  284. return create_symbolic_link_api(lpSymlinkFileName, lpTargetFileName, dwFlags);
  285. #else
  286. assert(false && "Not implemented for Unix");
  287. return false;
  288. #endif
  289. }
  290. bool MSFileSystemForDisk::SupportsCreateSymbolicLink() throw()
  291. {
  292. #ifdef _WIN32
  293. return create_symbolic_link_api != nullptr;
  294. #else
  295. assert(false && "Not implemented for Unix");
  296. return false;
  297. #endif
  298. }
  299. _Use_decl_annotations_
  300. BOOL MSFileSystemForDisk::ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, _Out_opt_ LPDWORD lpNumberOfBytesRead) throw()
  301. {
  302. #ifdef _WIN32
  303. return ::ReadFile(hFile, lpBuffer, nNumberOfBytesToRead, lpNumberOfBytesRead, nullptr);
  304. #else
  305. assert(false && "Not implemented for Unix");
  306. return false;
  307. #endif
  308. }
  309. _Use_decl_annotations_
  310. HANDLE MSFileSystemForDisk::CreateFileMappingW(HANDLE hFile, DWORD flProtect, DWORD dwMaximumSizeHigh, DWORD dwMaximumSizeLow) throw()
  311. {
  312. #ifdef _WIN32
  313. return ::CreateFileMappingW(hFile, nullptr, flProtect, dwMaximumSizeHigh, dwMaximumSizeLow, nullptr);
  314. #else
  315. assert(false && "Not implemented for Unix");
  316. return nullptr;
  317. #endif
  318. }
  319. _Use_decl_annotations_
  320. LPVOID MSFileSystemForDisk::MapViewOfFile(HANDLE hFileMappingObject, DWORD dwDesiredAccess, DWORD dwFileOffsetHigh, DWORD dwFileOffsetLow, SIZE_T dwNumberOfBytesToMap) throw()
  321. {
  322. #ifdef _WIN32
  323. return ::MapViewOfFile(hFileMappingObject, dwDesiredAccess, dwFileOffsetHigh, dwFileOffsetLow, dwNumberOfBytesToMap);
  324. #else
  325. assert(false && "Not implemented for Unix");
  326. return nullptr;
  327. #endif
  328. }
  329. _Use_decl_annotations_
  330. BOOL MSFileSystemForDisk::UnmapViewOfFile(LPCVOID lpBaseAddress) throw()
  331. {
  332. #ifdef _WIN32
  333. return ::UnmapViewOfFile(lpBaseAddress);
  334. #else
  335. assert(false && "Not implemented for Unix");
  336. return false;
  337. #endif
  338. }
  339. bool MSFileSystemForDisk::FileDescriptorIsDisplayed(int fd) throw()
  340. {
  341. #ifdef _WIN32
  342. DWORD Mode; // Unused
  343. return (GetConsoleMode((HANDLE)_get_osfhandle(fd), &Mode) != 0);
  344. #else
  345. assert(false && "Not implemented for Unix");
  346. return false;
  347. #endif
  348. }
  349. unsigned MSFileSystemForDisk::GetColumnCount(DWORD nStdHandle) throw()
  350. {
  351. #ifdef _WIN32
  352. unsigned Columns = 0;
  353. CONSOLE_SCREEN_BUFFER_INFO csbi;
  354. if (::GetConsoleScreenBufferInfo(GetStdHandle(nStdHandle), &csbi))
  355. Columns = csbi.dwSize.X;
  356. return Columns;
  357. #else
  358. assert(false && "Not implemented for Unix");
  359. return 0;
  360. #endif
  361. }
  362. unsigned MSFileSystemForDisk::GetConsoleOutputTextAttributes() throw()
  363. {
  364. #ifdef _WIN32
  365. CONSOLE_SCREEN_BUFFER_INFO csbi;
  366. if (::GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi))
  367. return csbi.wAttributes;
  368. return 0;
  369. #else
  370. assert(false && "Not implemented for Unix");
  371. return 0;
  372. #endif
  373. }
  374. void MSFileSystemForDisk::SetConsoleOutputTextAttributes(unsigned attributes) throw()
  375. {
  376. #ifdef _WIN32
  377. ::SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), attributes);
  378. #else
  379. assert(false && "Not implemented for Unix");
  380. #endif
  381. }
  382. void MSFileSystemForDisk::ResetConsoleOutputTextAttributes() throw()
  383. {
  384. #ifdef _WIN32
  385. ::SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), _defaultAttributes);
  386. #else
  387. assert(false && "Not implemented for Unix");
  388. #endif
  389. }
  390. int MSFileSystemForDisk::open_osfhandle(intptr_t osfhandle, int flags) throw()
  391. {
  392. #ifdef _WIN32
  393. return ::_open_osfhandle(osfhandle, flags);
  394. #else
  395. assert(false && "Not implemented for Unix");
  396. return 0;
  397. #endif
  398. }
  399. intptr_t MSFileSystemForDisk::get_osfhandle(int fd) throw()
  400. {
  401. #ifdef _WIN32
  402. return ::_get_osfhandle(fd);
  403. #else
  404. assert(false && "Not implemented for Unix");
  405. return 0;
  406. #endif
  407. }
  408. int MSFileSystemForDisk::close(int fd) throw()
  409. {
  410. #ifdef _WIN32
  411. return ::_close(fd);
  412. #else
  413. return ::close(fd);
  414. #endif
  415. }
  416. long MSFileSystemForDisk::lseek(int fd, long offset, int origin) throw()
  417. {
  418. #ifdef _WIN32
  419. return ::_lseek(fd, offset, origin);
  420. #else
  421. return ::lseek(fd, offset, origin);
  422. #endif
  423. }
  424. int MSFileSystemForDisk::setmode(int fd, int mode) throw()
  425. {
  426. #ifdef _WIN32
  427. return ::_setmode(fd, mode);
  428. #else
  429. assert(false && "Not implemented for Unix");
  430. return 0;
  431. #endif
  432. }
  433. _Use_decl_annotations_
  434. errno_t MSFileSystemForDisk::resize_file(LPCWSTR path, uint64_t size) throw()
  435. {
  436. #ifdef _WIN32
  437. int fd = ::_wopen(path, O_BINARY | _O_RDWR, S_IWRITE);
  438. if (fd == -1)
  439. return errno;
  440. #ifdef HAVE__CHSIZE_S
  441. errno_t error = ::_chsize_s(fd, size);
  442. #else
  443. errno_t error = ::_chsize(fd, size);
  444. #endif
  445. ::_close(fd);
  446. return error;
  447. #else
  448. assert(false && "Not implemented for Unix");
  449. return 0;
  450. #endif
  451. }
  452. _Use_decl_annotations_
  453. int MSFileSystemForDisk::Read(int fd, void* buffer, unsigned int count) throw()
  454. {
  455. #ifdef _WIN32
  456. return ::_read(fd, buffer, count);
  457. #else
  458. return ::read(fd, buffer, count);
  459. #endif
  460. }
  461. _Use_decl_annotations_
  462. int MSFileSystemForDisk::Write(int fd, const void* buffer, unsigned int count) throw()
  463. {
  464. #ifdef _WIN32
  465. return ::_write(fd, buffer, count);
  466. #else
  467. return ::write(fd, buffer, count);
  468. #endif
  469. }
  470. #ifndef _WIN32
  471. int MSFileSystemForDisk::Open(const char *lpFileName, int flags, mode_t mode) throw() {
  472. return ::open(lpFileName, flags, mode);
  473. }
  474. int MSFileSystemForDisk::Stat(const char *lpFileName, struct stat *Status) throw() {
  475. return ::stat(lpFileName, Status);
  476. }
  477. int MSFileSystemForDisk::Fstat(int FD, struct stat *Status) throw() {
  478. return ::fstat(FD, Status);
  479. }
  480. #endif
  481. } // end namespace fs
  482. } // end namespace sys
  483. } // end namespace llvm
  484. ///////////////////////////////////////////////////////////////////////////////////////////////////
  485. // Externally visible functions.
  486. HRESULT CreateMSFileSystemForDisk(_COM_Outptr_ ::llvm::sys::fs::MSFileSystem** pResult) throw()
  487. {
  488. *pResult = new (std::nothrow) ::llvm::sys::fs::MSFileSystemForDisk();
  489. return (*pResult != nullptr) ? S_OK : E_OUTOFMEMORY;
  490. }