MSFileSystem.h 5.4 KB

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