From 120652acc2832081117d2bbef8c98e6de012d254 Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Fri, 1 Apr 2016 00:13:31 +0000 Subject: [PATCH] Revert "Add disk_space() to llvm::fs" This reverts commit r265074 and r265068. Breaks windows build From: Mehdi Amini git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265080 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/FileSystem.h | 12 ------------ lib/Support/Unix/Path.inc | 32 +------------------------------ lib/Support/Windows/Path.inc | 13 ------------- 3 files changed, 1 insertion(+), 56 deletions(-) diff --git a/include/llvm/Support/FileSystem.h b/include/llvm/Support/FileSystem.h index 3d780236f12..4a4c3f493a5 100644 --- a/include/llvm/Support/FileSystem.h +++ b/include/llvm/Support/FileSystem.h @@ -32,7 +32,6 @@ #include "llvm/ADT/Twine.h" #include "llvm/Support/DataTypes.h" #include "llvm/Support/ErrorHandling.h" -#include "llvm/Support/ErrorOr.h" #include "llvm/Support/TimeValue.h" #include #include @@ -649,17 +648,6 @@ std::error_code identify_magic(const Twine &path, file_magic &result); std::error_code getUniqueID(const Twine Path, UniqueID &Result); -/// @brief Get disk space usage information. -/// -/// Note: Users must be careful about "Time Of Check, Time Of Use" kind of bug. -/// Note: Windows reports results according to the quota allocated to the user. -/// -/// @param Path Input path. -/// @returns a space_info structure filled with the capacity, free, and -/// available space on the device \a Path is on. A platform specific error_code -/// is returned on error. -ErrorOr disk_space(const Twine &Path); - /// This class represents a memory mapped file. It is based on /// boost::iostreams::mapped_file. class mapped_file_region { diff --git a/lib/Support/Unix/Path.inc b/lib/Support/Unix/Path.inc index 3cedf64d4b0..a80e0ddb8a1 100644 --- a/lib/Support/Unix/Path.inc +++ b/lib/Support/Unix/Path.inc @@ -60,24 +60,6 @@ # define PATH_MAX 4096 #endif -#include -#if !defined(__APPLE__) && !defined(__OpenBSD__) && !defined(__ANDROID__) -#include -#define STATVFS statvfs -#define STATVFS_F_FRSIZE(vfs) vfs.f_frsize -#else -#ifdef __OpenBSD__ -#include -#elif defined(__ANDROID__) -#include -#else -#include -#endif -#define STATVFS statfs -#define STATVFS_F_FRSIZE(vfs) static_cast(vfs.f_bsize) -#endif - - using namespace llvm; namespace llvm { @@ -88,7 +70,7 @@ namespace fs { defined(__linux__) || defined(__CYGWIN__) || defined(__DragonFly__) static int test_dir(char ret[PATH_MAX], const char *dir, const char *bin) -{ +{ struct stat sb; char fullpath[PATH_MAX]; @@ -208,18 +190,6 @@ UniqueID file_status::getUniqueID() const { return UniqueID(fs_st_dev, fs_st_ino); } -ErrorOr disk_space(const Twine &Path) { - struct STATVFS Vfs; - if (::STATVFS(Path.str().c_str(), &Vfs)) - return std::error_code(errno, std::generic_category()); - auto FrSize = STATVFS_F_FRSIZE(Vfs); - space_info SpaceInfo; - SpaceInfo.capacity = static_cast(Vfs.f_blocks) * FrSize; - SpaceInfo.free = static_cast(Vfs.f_bfree) * FrSize; - SpaceInfo.available = static_cast(Vfs.f_bavail) * FrSize; - return SpaceInfo; -} - std::error_code current_path(SmallVectorImpl &result) { result.clear(); diff --git a/lib/Support/Windows/Path.inc b/lib/Support/Windows/Path.inc index c17c5c61b5a..98fd7b0034a 100644 --- a/lib/Support/Windows/Path.inc +++ b/lib/Support/Windows/Path.inc @@ -151,19 +151,6 @@ UniqueID file_status::getUniqueID() const { return UniqueID(VolumeSerialNumber, FileID); } -ErrorOr 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(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;