summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Windows
diff options
context:
space:
mode:
authorMehdi Amini <mehdi.amini@apple.com>2016-03-31 23:05:26 +0000
committerMehdi Amini <mehdi.amini@apple.com>2016-03-31 23:05:26 +0000
commit4c82356ad323db57c861f5422ba0b34c96cf2db0 (patch)
tree51c26452eee040a8192fd901906d071e7336d249 /llvm/lib/Support/Windows
parent2e24d0c0c1071eb873b30dd8b6d62b0153a959e5 (diff)
downloadbcm5719-llvm-4c82356ad323db57c861f5422ba0b34c96cf2db0.tar.gz
bcm5719-llvm-4c82356ad323db57c861f5422ba0b34c96cf2db0.zip
Add disk_space() to llvm::fs
Summary: Adapted from Boost::filesystem. (This is a reapply by reverting commit r265062 and fixing the WinAPI part) Differential Revision: http://reviews.llvm.org/D18467 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 265068
Diffstat (limited to 'llvm/lib/Support/Windows')
-rw-r--r--llvm/lib/Support/Windows/Path.inc13
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/lib/Support/Windows/Path.inc b/llvm/lib/Support/Windows/Path.inc
index 98fd7b0034a..72604c0e406 100644
--- a/llvm/lib/Support/Windows/Path.inc
+++ b/llvm/lib/Support/Windows/Path.inc
@@ -151,6 +151,19 @@ UniqueID file_status::getUniqueID() const {
return UniqueID(VolumeSerialNumber, FileID);
}
+ErrorOr<space_info> disk_space(const Twine Path) {
+ PULARGE_INTEGER Avail, Total, Free;
+ if (!::GetDiskFreeSpaceExA(Path.str().c_str(), &Avail, &Total, &Free))
+ return mapWindowsError(::GetLastError());
+ space_info SpaceInfo;
+ SpaceInfo.capacity =
+ (static_cast<uint64_t>(Total.HighPart) << 32) + Total.LowPart;
+ SpaceInfo.Free = (static_cast<uint64_t>(Free.HighPart) << 32) + Free.LowPart;
+ SpaceInfo.available =
+ (static_cast<uint64_t>(Avail.HighPart) << 32) + Avail.LowPart;
+ return SpaceInfo;
+}
+
TimeValue file_status::getLastAccessedTime() const {
ULARGE_INTEGER UI;
UI.LowPart = LastAccessedTimeLow;
OpenPOWER on IntegriCloud