aboutsummaryrefslogtreecommitdiff
path: root/lib/Support/Windows/PathV2.inc
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2010-12-04 00:31:48 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2010-12-04 00:31:48 +0000
commit01a87c413d9fcf03e717c4ebde8554e986f6f7cb (patch)
tree98fcfab31d22632fbf1a9b3c177d1011de0338fc /lib/Support/Windows/PathV2.inc
parent767b1be3900bdc693aa0ad3e554ba034845f67f7 (diff)
Support/FileSystem: Add file_size implementation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120867 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/Windows/PathV2.inc')
-rw-r--r--lib/Support/Windows/PathV2.inc21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/Support/Windows/PathV2.inc b/lib/Support/Windows/PathV2.inc
index e7aa93b6e4..dd7fefafc6 100644
--- a/lib/Support/Windows/PathV2.inc
+++ b/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.