diff options
author | Michael J. Spencer <bigcheesegs@gmail.com> | 2010-12-04 00:31:48 +0000 |
---|---|---|
committer | Michael J. Spencer <bigcheesegs@gmail.com> | 2010-12-04 00:31:48 +0000 |
commit | 818ab4aad42d0e0b2abba2f8248a0709eaea3045 (patch) | |
tree | 6107180ccbaa75258eee06ab135c17940493449e /llvm/lib/Support/Windows | |
parent | 1048e75fb9f76233152e3848cef65c18d6d39e03 (diff) | |
download | bcm5719-llvm-818ab4aad42d0e0b2abba2f8248a0709eaea3045.tar.gz bcm5719-llvm-818ab4aad42d0e0b2abba2f8248a0709eaea3045.zip |
Support/FileSystem: Add file_size implementation.
llvm-svn: 120867
Diffstat (limited to 'llvm/lib/Support/Windows')
-rw-r--r-- | llvm/lib/Support/Windows/PathV2.inc | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/llvm/lib/Support/Windows/PathV2.inc b/llvm/lib/Support/Windows/PathV2.inc index e7aa93b6e4e..dd7fefafc69 100644 --- a/llvm/lib/Support/Windows/PathV2.inc +++ b/llvm/lib/Support/Windows/PathV2.inc @@ -406,6 +406,27 @@ error_code equivalent(const Twine &A, const Twine &B, bool &result) { return make_error_code(errc::success); } +error_code file_size(const Twine &path, uint64_t &result) { + SmallString<128> path_storage; + SmallVector<wchar_t, 128> path_utf16; + + if (error_code ec = UTF8ToUTF16(path.toStringRef(path_storage), + path_utf16)) + return ec; + + WIN32_FILE_ATTRIBUTE_DATA FileData; + if (!::GetFileAttributesExW(path_utf16.begin(), + ::GetFileExInfoStandard, + &FileData)) + return make_error_code(windows_error(::GetLastError())); + + result = + (uint64_t(FileData.nFileSizeHigh) << (sizeof(FileData.nFileSizeLow) * 8)) + + FileData.nFileSizeLow; + + return make_error_code(errc::success); +} + error_code unique_file(const Twine &model, int &result_fd, SmallVectorImpl<char> &result_path) { // Use result_path as temp storage. |