Changes in directory llvm/lib/System/Unix:
Path.inc updated: 1.58 -> 1.59 --- Log message: For PR789: http://llvm.org/PR789 : * Add a method: bool isAbsolute() const, which determines if the path name is absolute or not. * Implement caching of file status information in the Path object. Allow it to be updated forcefully or lazily re-fetched from the cached value. --- Diffs of the changes: (+22 -12) Path.inc | 34 ++++++++++++++++++++++------------ 1 files changed, 22 insertions(+), 12 deletions(-) Index: llvm/lib/System/Unix/Path.inc diff -u llvm/lib/System/Unix/Path.inc:1.58 llvm/lib/System/Unix/Path.inc:1.59 --- llvm/lib/System/Unix/Path.inc:1.58 Wed Aug 23 15:34:57 2006 +++ llvm/lib/System/Unix/Path.inc Thu Mar 29 11:43:20 2007 @@ -79,6 +79,12 @@ return i >= len; } +bool +Path::isAbsolute() const { + if (path.empty()) + return false; + return path[0] == '/'; +} Path Path::GetRootDirectory() { Path result; @@ -357,18 +363,22 @@ } bool -Path::getFileStatus(FileStatus &info, std::string *ErrStr) const { - struct stat buf; - if (0 != stat(path.c_str(), &buf)) - return MakeErrMsg(ErrStr, - path + ": can't get status of file '" + path + "'"); - info.fileSize = buf.st_size; - info.modTime.fromEpochTime(buf.st_mtime); - info.mode = buf.st_mode; - info.user = buf.st_uid; - info.group = buf.st_gid; - info.isDir = S_ISDIR(buf.st_mode); - info.isFile = S_ISREG(buf.st_mode); +Path::getFileStatus(FileStatus &info, bool update, std::string *ErrStr) const { + if (status == 0 || update) { + struct stat buf; + if (0 != stat(path.c_str(), &buf)) + return MakeErrMsg(ErrStr, path + ": can't get status of file"); + if (status == 0) + status = new FileStatus; + status->fileSize = buf.st_size; + status->modTime.fromEpochTime(buf.st_mtime); + status->mode = buf.st_mode; + status->user = buf.st_uid; + status->group = buf.st_gid; + status->isDir = S_ISDIR(buf.st_mode); + status->isFile = S_ISREG(buf.st_mode); + } + info = *status; return false; } _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits