MSFileSystem.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // //
  3. // MSFileSystem.h //
  4. // Copyright (C) Microsoft Corporation. All rights reserved. //
  5. // This file is distributed under the University of Illinois Open Source //
  6. // License. See LICENSE.TXT for details. //
  7. // //
  8. // Provides error code values for the DirectX compiler. //
  9. // //
  10. ///////////////////////////////////////////////////////////////////////////////
  11. #ifndef LLVM_SUPPORT_MSFILESYSTEM_H
  12. #define LLVM_SUPPORT_MSFILESYSTEM_H
  13. ///////////////////////////////////////////////////////////////////////////////////////////////////
  14. // MSFileSystem interface.
  15. struct stat;
  16. namespace llvm {
  17. namespace sys {
  18. namespace fs {
  19. class MSFileSystem
  20. {
  21. public:
  22. virtual ~MSFileSystem() { };
  23. virtual BOOL FindNextFileW(
  24. _In_ HANDLE hFindFile,
  25. _Out_ LPWIN32_FIND_DATAW lpFindFileData) throw() = 0;
  26. virtual HANDLE FindFirstFileW(
  27. _In_ LPCWSTR lpFileName,
  28. _Out_ LPWIN32_FIND_DATAW lpFindFileData) throw() = 0;
  29. virtual void FindClose(HANDLE findHandle) throw() = 0;
  30. virtual HANDLE CreateFileW(
  31. _In_ LPCWSTR lpFileName,
  32. _In_ DWORD dwDesiredAccess,
  33. _In_ DWORD dwShareMode,
  34. _In_ DWORD dwCreationDisposition,
  35. _In_ DWORD dwFlagsAndAttributes) throw() = 0;
  36. virtual BOOL SetFileTime(_In_ HANDLE hFile,
  37. _In_opt_ const FILETIME *lpCreationTime,
  38. _In_opt_ const FILETIME *lpLastAccessTime,
  39. _In_opt_ const FILETIME *lpLastWriteTime) throw() = 0;
  40. virtual BOOL GetFileInformationByHandle(_In_ HANDLE hFile, _Out_ LPBY_HANDLE_FILE_INFORMATION lpFileInformation) throw() = 0;
  41. virtual DWORD GetFileType(_In_ HANDLE hFile) throw() = 0;
  42. virtual BOOL CreateHardLinkW(_In_ LPCWSTR lpFileName, _In_ LPCWSTR lpExistingFileName) throw() = 0;
  43. virtual BOOL MoveFileExW(_In_ LPCWSTR lpExistingFileName, _In_opt_ LPCWSTR lpNewFileName, _In_ DWORD dwFlags) throw() = 0;
  44. virtual DWORD GetFileAttributesW(_In_ LPCWSTR lpFileName) throw() = 0;
  45. virtual BOOL CloseHandle(_In_ HANDLE hObject) throw() = 0;
  46. virtual BOOL DeleteFileW(_In_ LPCWSTR lpFileName) throw() = 0;
  47. virtual BOOL RemoveDirectoryW(_In_ LPCWSTR lpFileName) throw() = 0;
  48. virtual BOOL CreateDirectoryW(_In_ LPCWSTR lpPathName) throw() = 0;
  49. _Success_(return != 0 && return < nBufferLength)
  50. virtual DWORD GetCurrentDirectoryW(_In_ DWORD nBufferLength, _Out_writes_to_opt_(nBufferLength, return + 1) LPWSTR lpBuffer) throw() = 0;
  51. _Success_(return != 0 && return < nSize)
  52. virtual DWORD GetMainModuleFileNameW(__out_ecount_part(nSize, return + 1) LPWSTR lpFilename, DWORD nSize) throw() = 0;
  53. virtual DWORD GetTempPathW(DWORD nBufferLength, _Out_writes_to_opt_(nBufferLength, return + 1) LPWSTR lpBuffer) throw() = 0;
  54. virtual BOOLEAN CreateSymbolicLinkW(_In_ LPCWSTR lpSymlinkFileName, _In_ LPCWSTR lpTargetFileName, DWORD dwFlags) throw() = 0;
  55. virtual bool SupportsCreateSymbolicLink() throw() = 0;
  56. virtual BOOL ReadFile(_In_ HANDLE hFile, _Out_bytecap_(nNumberOfBytesToRead) LPVOID lpBuffer, _In_ DWORD nNumberOfBytesToRead, _Out_opt_ LPDWORD lpNumberOfBytesRead) throw() = 0;
  57. virtual HANDLE CreateFileMappingW(
  58. _In_ HANDLE hFile,
  59. _In_ DWORD flProtect,
  60. _In_ DWORD dwMaximumSizeHigh,
  61. _In_ DWORD dwMaximumSizeLow) throw() = 0;
  62. virtual LPVOID MapViewOfFile(
  63. _In_ HANDLE hFileMappingObject,
  64. _In_ DWORD dwDesiredAccess,
  65. _In_ DWORD dwFileOffsetHigh,
  66. _In_ DWORD dwFileOffsetLow,
  67. _In_ SIZE_T dwNumberOfBytesToMap) throw() = 0;
  68. virtual BOOL UnmapViewOfFile(_In_ LPCVOID lpBaseAddress) throw() = 0;
  69. // Console APIs.
  70. virtual bool FileDescriptorIsDisplayed(int fd) throw() = 0;
  71. virtual unsigned GetColumnCount(DWORD nStdHandle) throw() = 0;
  72. virtual unsigned GetConsoleOutputTextAttributes() throw() = 0;
  73. virtual void SetConsoleOutputTextAttributes(unsigned) throw() = 0;
  74. virtual void ResetConsoleOutputTextAttributes() throw() = 0;
  75. // CRT APIs.
  76. virtual int open_osfhandle(intptr_t osfhandle, int flags) throw() = 0;
  77. virtual intptr_t get_osfhandle(int fd) throw() = 0;
  78. virtual int close(int fd) throw() = 0;
  79. virtual long lseek(int fd, long offset, int origin) throw() = 0;
  80. virtual int setmode(int fd, int mode) throw() = 0;
  81. virtual errno_t resize_file(_In_ LPCWSTR path, uint64_t size) throw() = 0; // A number of C calls.
  82. virtual int Read(int fd, _Out_bytecap_(count) void* buffer, unsigned int count) throw() = 0;
  83. virtual int Write(int fd, _In_bytecount_(count) const void* buffer, unsigned int count) throw() = 0;
  84. // Unix interface
  85. #ifndef _WIN32
  86. virtual int Open(const char *lpFileName, int flags, mode_t mode = 0) throw() = 0;
  87. virtual int Stat(const char *lpFileName, struct stat *Status) throw() = 0;
  88. virtual int Fstat(int FD, struct stat *Status) throw() = 0;
  89. #endif
  90. };
  91. } // end namespace fs
  92. } // end namespace sys
  93. } // end namespace llvm
  94. /// <summary>Creates a Win32/CRT-based implementation with full fidelity for a console program.</summary>
  95. /// <remarks>This requires the LLVM MS Support library to be linked in.</remarks>
  96. HRESULT CreateMSFileSystemForDisk(_COM_Outptr_ ::llvm::sys::fs::MSFileSystem** pResult) throw();
  97. struct IUnknown;
  98. /// <summary>Creates an implementation based on IDxcSystemAccess.</summary>
  99. HRESULT CreateMSFileSystemForIface(_In_ IUnknown* pService, _COM_Outptr_::llvm::sys::fs::MSFileSystem** pResult) throw();
  100. #endif // LLVM_SUPPORT_MSFILESYSTEM_H