diff options
author | Nick Kledzik <kledzik@apple.com> | 2012-06-20 00:28:54 +0000 |
---|---|---|
committer | Nick Kledzik <kledzik@apple.com> | 2012-06-20 00:28:54 +0000 |
commit | ca077ec5ea41f4537ae58e141781be622d09c786 (patch) | |
tree | 2dc2a2955b3f6c9b950d0fc907d99a18a3375b5b /lib/Support/Windows | |
parent | 44b2c82871fad5407930cdf0b90c578fa4e60a3a (diff) | |
download | llvm-ca077ec5ea41f4537ae58e141781be622d09c786.tar.gz llvm-ca077ec5ea41f4537ae58e141781be622d09c786.tar.bz2 llvm-ca077ec5ea41f4537ae58e141781be622d09c786.tar.xz |
Add permissions(), map_file_pages(), and unmap_file_pages() to llvm::sys::fs and add unit test. Unix is implemented. Windows side needs to be implemented.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158770 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/Windows')
-rw-r--r-- | lib/Support/Windows/PathV2.inc | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/lib/Support/Windows/PathV2.inc b/lib/Support/Windows/PathV2.inc index 4868b184b8..c79d8ab0aa 100644 --- a/lib/Support/Windows/PathV2.inc +++ b/lib/Support/Windows/PathV2.inc @@ -497,6 +497,41 @@ handle_status_error: return error_code::success(); } + +// Modifies permissions on a file. +error_code permissions(const Twine &path, perms prms) { +#if 0 // verify code below before enabling: + // If the permissions bits are not trying to modify + // "write" permissions, there is nothing to do. + if (!(prms & (owner_write|group_write|others_write))) + return error_code::success(); + + SmallString<128> path_storage; + SmallVector<wchar_t, 128> path_utf16; + + if (error_code ec = UTF8ToUTF16(path.toStringRef(path_storage), + path_utf16)) + return ec; + + DWORD attributes = ::GetFileAttributesW(path_utf16.begin()); + + if (prms & add_perms) { + attributes &= ~FILE_ATTRIBUTE_READONLY; + } + else if (prms & remove_perms) { + attributes |= FILE_ATTRIBUTE_READONLY; + } + else { + assert(0 && "neither add_perms or remove_perms is set"); + } + + if ( ! ::SetFileAttributesW(path_utf16.begin(), attributes)) + return windows_error(::GetLastError()); +#endif + return error_code::success(); +} + + // FIXME: mode should be used here and default to user r/w only, // it currently comes in as a UNIX mode. error_code unique_file(const Twine &model, int &result_fd, @@ -755,6 +790,17 @@ error_code detail::directory_iterator_increment(detail::DirIterState &it) { return error_code::success(); } +error_code map_file_pages(const Twine &path, off_t file_offset, size_t size, + bool map_writable, void *&result) { + assert(0 && "NOT IMPLEMENTED"); +} + +error_code unmap_file_pages(void *base, size_t size) { + assert(0 && "NOT IMPLEMENTED"); +} + + + } // end namespace fs } // end namespace sys } // end namespace llvm |