From e2d8f1b8fc42b611e267a47563645e4029e0d75f Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Fri, 1 Apr 2016 00:18:08 +0000 Subject: Add disk_space() to llvm::fs Summary: Adapted from Boost::filesystem. (This is a reapply by reverting commit r265080 and fixing the WinAPI part) Differential Revision: http://reviews.llvm.org/D18467 From: Mehdi Amini llvm-svn: 265082 --- llvm/lib/Support/Windows/Path.inc | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'llvm/lib/Support/Windows') diff --git a/llvm/lib/Support/Windows/Path.inc b/llvm/lib/Support/Windows/Path.inc index 98fd7b0034a..068ed357819 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 disk_space(const Twine &Path) { + ULARGE_INTEGER Avail, Total, Free; + if (!::GetDiskFreeSpaceExA(Path.str().c_str(), &Avail, &Total, &Free)) + return mapWindowsError(::GetLastError()); + space_info SpaceInfo; + SpaceInfo.capacity = + (static_cast(Total.HighPart) << 32) + Total.LowPart; + SpaceInfo.Free = (static_cast(Free.HighPart) << 32) + Free.LowPart; + SpaceInfo.available = + (static_cast(Avail.HighPart) << 32) + Avail.LowPart; + return SpaceInfo; +} + TimeValue file_status::getLastAccessedTime() const { ULARGE_INTEGER UI; UI.LowPart = LastAccessedTimeLow; -- cgit v1.2.3