diff options
author | Chris Lattner <sabre@nondot.org> | 2003-12-30 07:36:14 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-12-30 07:36:14 +0000 |
commit | 316cb083d66a38cf5d5975b974099c879e126341 (patch) | |
tree | ae19ff7d12a4d344c2024a9ebe18005ab890e773 /lib/Support/FileUtilities.cpp | |
parent | 9c4c66e70ea30a9bffeeac446d6d5294d1098198 (diff) |
Add new method
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10649 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/FileUtilities.cpp')
-rw-r--r-- | lib/Support/FileUtilities.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/Support/FileUtilities.cpp b/lib/Support/FileUtilities.cpp index 9471710b1d..04b8c610a2 100644 --- a/lib/Support/FileUtilities.cpp +++ b/lib/Support/FileUtilities.cpp @@ -195,6 +195,16 @@ bool llvm::MakeFileReadable(const std::string &Filename) { return AddPermissionsBits(Filename, 0444); } +/// getFileSize - Return the size of the specified file in bytes, or -1 if the +/// file cannot be read or does not exist. +long long llvm::getFileSize(const std::string &Filename) { + struct stat StatBuf; + if (stat(Filename.c_str(), &StatBuf) == -1) + return -1; + return StatBuf.st_size; +} + + //===----------------------------------------------------------------------===// // FDHandle class implementation // |