Use status to implement file_size.

The status function is already using a syscall that returns the file size.
Remember it and implement file_size as a simple wrapper.

No functionally change, but clients that already use status now can avoid
calling file_size.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186016 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola
2013-07-10 17:16:40 +00:00
parent 43ae5e85f8
commit ac2de33d2a
3 changed files with 14 additions and 36 deletions
+1 -14
View File
@@ -529,20 +529,6 @@ error_code equivalent(const Twine &A, const Twine &B, bool &result) {
return error_code::success();
}
error_code file_size(const Twine &path, uint64_t &result) {
SmallString<128> path_storage;
StringRef p = path.toNullTerminatedStringRef(path_storage);
struct stat status;
if (::stat(p.begin(), &status) == -1)
return error_code(errno, system_category());
if (!S_ISREG(status.st_mode))
return make_error_code(errc::operation_not_permitted);
result = status.st_size;
return error_code::success();
}
error_code getUniqueID(const Twine Path, uint64_t &Result) {
SmallString<128> Storage;
StringRef P = Path.toNullTerminatedStringRef(Storage);
@@ -591,6 +577,7 @@ error_code status(const Twine &path, file_status &result) {
result.fs_st_mtime = status.st_mtime;
result.fs_st_uid = status.st_uid;
result.fs_st_gid = status.st_gid;
result.fs_st_size = status.st_size;
return error_code::success();
}