For PR351: \

The getFileTimestamp and getFileSize functions have been removed from  \
FileUtilities.{h,cpp}. They are replaced by Path::getTimestamp and  \
Path::getSize,respectively.

llvm-svn: 18892
This commit is contained in:
Reid Spencer 2004-12-13 17:01:53 +00:00
parent fe4882b78e
commit dd50ab43d0
6 changed files with 27 additions and 39 deletions

View 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.

View 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

View 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

View 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;

View 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));

View 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());
}