summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Windows/Path.inc
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-06-11 22:53:00 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-06-11 22:53:00 +0000
commitda70bfd82650d80ee43e9c6ff5f202da959ef09b (patch)
tree4b1bcc747cc94d9b87e9daa8b2c5e9755cff27c5 /llvm/lib/Support/Windows/Path.inc
parente8ad3839a19e0731b8c8ba716263ecbea0223c03 (diff)
downloadbcm5719-llvm-da70bfd82650d80ee43e9c6ff5f202da959ef09b.tar.gz
bcm5719-llvm-da70bfd82650d80ee43e9c6ff5f202da959ef09b.zip
Implement get_magic with generic tools and inline it.
llvm-svn: 210716
Diffstat (limited to 'llvm/lib/Support/Windows/Path.inc')
-rw-r--r--llvm/lib/Support/Windows/Path.inc42
1 files changed, 0 insertions, 42 deletions
diff --git a/llvm/lib/Support/Windows/Path.inc b/llvm/lib/Support/Windows/Path.inc
index fb484778e65..6a5792e70c1 100644
--- a/llvm/lib/Support/Windows/Path.inc
+++ b/llvm/lib/Support/Windows/Path.inc
@@ -466,48 +466,6 @@ error_code setLastModificationAndAccessTime(int FD, TimeValue Time) {
return error_code();
}
-error_code get_magic(const Twine &path, uint32_t len,
- SmallVectorImpl<char> &result) {
- SmallString<128> path_storage;
- SmallVector<wchar_t, 128> path_utf16;
- result.set_size(0);
-
- // Convert path to UTF-16.
- if (error_code ec = UTF8ToUTF16(path.toStringRef(path_storage),
- path_utf16))
- return ec;
-
- // Open file.
- HANDLE file = ::CreateFileW(c_str(path_utf16),
- GENERIC_READ,
- FILE_SHARE_READ,
- NULL,
- OPEN_EXISTING,
- FILE_ATTRIBUTE_READONLY,
- NULL);
- if (file == INVALID_HANDLE_VALUE)
- return windows_error(::GetLastError());
-
- // Allocate buffer.
- result.reserve(len);
-
- // Get magic!
- DWORD bytes_read = 0;
- BOOL read_success = ::ReadFile(file, result.data(), len, &bytes_read, NULL);
- error_code ec = windows_error(::GetLastError());
- ::CloseHandle(file);
- if (!read_success || (bytes_read != len)) {
- // Set result size to the number of bytes read if it's valid.
- if (bytes_read <= len)
- result.set_size(bytes_read);
- // ERROR_HANDLE_EOF is mapped to errc::value_too_large.
- return ec;
- }
-
- result.set_size(len);
- return error_code();
-}
-
error_code mapped_file_region::init(int FD, bool CloseFD, uint64_t Offset) {
FileDescriptor = FD;
// Make sure that the requested size fits within SIZE_T.
OpenPOWER on IntegriCloud