Add new method
authorChris Lattner <sabre@nondot.org>
Tue, 30 Dec 2003 07:36:14 +0000 (07:36 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 30 Dec 2003 07:36:14 +0000 (07:36 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10649 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/FileUtilities.cpp

index 9471710b1d591014082cfb03b06967ba4b6549f5..04b8c610a27d837d28b3acf6795cacb9e0892710 100644 (file)
@@ -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
 //