For PR351: \
authorReid Spencer <rspencer@reidspencer.com>
Mon, 13 Dec 2004 17:01:53 +0000 (17:01 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Mon, 13 Dec 2004 17:01:53 +0000 (17:01 +0000)
The getFileTimestamp and getFileSize functions have been removed from  \
FileUtilities.{h,cpp}. They are replaced by Path::getTimestamp and  \
Path::getSize,respectively.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18892 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Debugger/ProgramInfo.h
include/llvm/Support/FileUtilities.h
include/llvm/System/Path.h
lib/Debugger/ProgramInfo.cpp
lib/Support/FileUtilities.cpp
tools/llvm-db/Commands.cpp

index 4420e724189d3b3170a8ed3b0a701ce227ba56ff..f7ee77dc314496be8eb139fdf5e87dd57cbccea9 100644 (file)
@@ -21,6 +21,7 @@
 #ifndef LLVM_DEBUGGER_PROGRAMINFO_H
 #define LLVM_DEBUGGER_PROGRAMINFO_H
 
+#include "llvm/System/TimeValue.h"
 #include <string>
 #include <map>
 #include <vector>
@@ -133,7 +134,7 @@ namespace llvm {
 
     /// ProgramTimeStamp - This is the timestamp of the executable file that we
     /// currently have loaded into the debugger.
-    unsigned long long ProgramTimeStamp;
+    sys::TimeValue ProgramTimeStamp;
 
     /// SourceFiles - This map is used to transform source file descriptors into
     /// their corresponding SourceFileInfo objects.  This mapping owns the
@@ -170,7 +171,7 @@ namespace llvm {
 
     /// getProgramTimeStamp - Return the time-stamp of the program when it was
     /// loaded.
-    unsigned long long getProgramTimeStamp() const { return ProgramTimeStamp; }
+    sys::TimeValue getProgramTimeStamp() const { return ProgramTimeStamp; }
     
     //===------------------------------------------------------------------===//
     // Interfaces to the source code files that make up the program.
index f61ee7c64055549cd3e45ea60430a20ce7a6b124..885ee86c0d306b88c3943d44e638306db3352333 100644 (file)
@@ -61,17 +61,6 @@ bool MakeFileExecutable(const std::string &Filename);
 ///
 bool MakeFileReadable(const std::string &Filename);
 
-/// getFileSize - Return the size of the specified file in bytes, or -1 if the
-/// file cannot be read or does not exist.
-long long getFileSize(const std::string &Filename);
-
-
-/// getFileTimestamp - Get the last modified time for the specified file in an
-/// unspecified format.  This is useful to allow checking to see if a file was
-/// updated since that last time the timestampt was aquired.  If the file does
-/// not exist or there is an error getting the time-stamp, zero is returned.
-unsigned long long getFileTimestamp(const std::string &Filename);
-
 /// ReadFileIntoAddressSpace - Attempt to map the specific file into the 
 /// address space of the current process for reading.  If this succeeds, 
 /// return the address of the buffer and the length of the file mapped.  On 
index 10c8bccef88e67ad1a2cccf247de861dfc0963b3..57cbc6c64d905d3799a0a1e8d717d06f10735f38 100644 (file)
@@ -376,6 +376,21 @@ namespace sys {
       /// @brief Get file status.
       void getStatusInfo(StatusInfo& info) const;
 
+      /// This function returns the last modified time stamp for the file 
+      /// referenced by this path. The Path may reference a file or a directory.
+      /// If the file does not exist, a ZeroTime timestamp is returned.
+      /// @returns last modified timestamp of the file/directory or ZeroTime
+      /// @brief Get file timestamp.
+      inline TimeValue getTimestamp() const {
+        StatusInfo info; getStatusInfo(info); return info.modTime;
+      }
+
+      /// This function returns the size of the file referenced by this path. 
+      /// @brief Get file size.
+      inline size_t getSize() const {
+        StatusInfo info; getStatusInfo(info); return info.fileSize;
+      }
+
       /// This method attempts to set the Path object to \p unverified_path
       /// and interpret the name as a directory name.  The \p unverified_path 
       /// is verified. If verification succeeds then \p unverified_path 
index c6e5d32b6668f7bc5e9c3fe9b8cfa38023a9eaeb..c0d85f97e456e3e6eb53028d5ceb63226e995020 100644 (file)
@@ -236,9 +236,10 @@ void SourceFunctionInfo::getSourceLocation(unsigned &RetLineNo,
 // ProgramInfo implementation
 //
 
-ProgramInfo::ProgramInfo(Module *m) : M(m) {
+ProgramInfo::ProgramInfo(Module *m) : M(m), ProgramTimeStamp(0,0) {
   assert(M && "Cannot create program information with a null module!");
-  ProgramTimeStamp = getFileTimestamp(M->getModuleIdentifier());
+  sys::Path modulePath(M->getModuleIdentifier());
+  ProgramTimeStamp = modulePath.getTimestamp();
 
   SourceFilesIsComplete = false;
   SourceFunctionsIsComplete = false;
index 5b7c56e950e2a0be2e17b5ea667bf78fa7332748..305f455937aafeed8a637437e6a2aad60bd73de2 100644 (file)
@@ -14,6 +14,7 @@
 
 #include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/DataTypes.h"
+#include "llvm/System/Path.h"
 #include "llvm/Config/unistd.h"
 #include "llvm/Config/fcntl.h"
 #include "llvm/Config/sys/types.h"
@@ -195,26 +196,6 @@ 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;  
-}
-
-/// getFileTimestamp - Get the last modified time for the specified file in an
-/// unspecified format.  This is useful to allow checking to see if a file was
-/// updated since that last time the timestampt was aquired.  If the file does
-/// not exist or there is an error getting the time-stamp, zero is returned.
-unsigned long long llvm::getFileTimestamp(const std::string &Filename) {
-  struct stat StatBuf;
-  if (stat(Filename.c_str(), &StatBuf) == -1)
-    return 0;
-  return StatBuf.st_mtime;  
-}
-
 /// ReadFileIntoAddressSpace - Attempt to map the specific file into the
 /// address space of the current process for reading.  If this succeeds,
 /// return the address of the buffer and the length of the file mapped.  On
@@ -222,7 +203,8 @@ unsigned long long llvm::getFileTimestamp(const std::string &Filename) {
 void *llvm::ReadFileIntoAddressSpace(const std::string &Filename, 
                                      unsigned &Length) {
 #if defined(HAVE_MMAP_FILE) && !defined(_MSC_VER)
-  Length = (unsigned)getFileSize(Filename);
+  sys::Path File(Filename);
+  Length = (unsigned)File.getSize();
   if ((int)Length == -1) return 0;
 
   FDHandle FD(open(Filename.c_str(), O_RDONLY));
index de7fdf604b787311e562dfaeffee2326d01010de..37f8a78209532d2a1995b7019cb972a28b37d6cb 100644 (file)
@@ -49,8 +49,8 @@ void CLIDebugger::startProgramRunning() {
   eliminateRunInfo();
 
   // If the program has been modified, reload it!
-  std::string Program = Dbg.getProgramPath();
-  if (TheProgramInfo->getProgramTimeStamp() != getFileTimestamp(Program)) {
+  sys::Path Program (Dbg.getProgramPath());
+  if (TheProgramInfo->getProgramTimeStamp() != Program.getTimestamp()) {
     std::cout << "'" << Program << "' has changed; re-reading program.\n";
 
     // Unload an existing program.  This kills the program if necessary.
@@ -59,7 +59,7 @@ void CLIDebugger::startProgramRunning() {
     TheProgramInfo = 0;
     CurrentFile = 0;
 
-    Dbg.loadProgram(Program);
+    Dbg.loadProgram(Program.toString());
     TheProgramInfo = new ProgramInfo(Dbg.getProgram());
   }