[llvm-commits] CVS: llvm/lib/System/Unix/Path.cpp

Reid Spencer reid at x10sys.com
Mon Nov 15 22:15:30 PST 2004



Changes in directory llvm/lib/System/Unix:

Path.cpp updated: 1.12 -> 1.13
---
Log message:

Per code review:
* Clean up the StatusInfo constructor to construct all members and give
  them reasonable values.
* Get rid of the Vector typedef and make the interface to 
  getDirectoryContent use a std::set instead of a std::vector so the dir
  content is sorted.
* Make the getStatusInfo method const and not return a useless boolean.


---
Diffs of the changes:  (+4 -7)

Index: llvm/lib/System/Unix/Path.cpp
diff -u llvm/lib/System/Unix/Path.cpp:1.12 llvm/lib/System/Unix/Path.cpp:1.13
--- llvm/lib/System/Unix/Path.cpp:1.12	Sun Nov 14 17:30:38 2004
+++ llvm/lib/System/Unix/Path.cpp	Tue Nov 16 00:15:19 2004
@@ -239,10 +239,8 @@
   return path.substr(pos+1);
 }
 
-bool
-Path::getStatusInfo(StatusInfo& info) {
-  if (!isFile() || !readable())
-    return false;
+void
+Path::getStatusInfo(StatusInfo& info) const {
   struct stat buf;
   if (0 != stat(path.c_str(), &buf)) {
     ThrowErrno(std::string("Can't get status: ")+path);
@@ -255,11 +253,10 @@
   info.isDir = S_ISDIR(buf.st_mode);
   if (info.isDir && path[path.length()-1] != '/')
     path += '/';
-  return true;
 }
 
 bool
-Path::getDirectoryContents(Vector& result) const {
+Path::getDirectoryContents(std::set<Path>& result) const {
   if (!isDirectory())
     return false;
   DIR* direntries = ::opendir(path.c_str());
@@ -276,7 +273,7 @@
         ThrowErrno(aPath.path + ": can't get status");
       if (S_ISDIR(buf.st_mode))
         aPath.path += "/";
-      result.push_back(aPath);
+      result.insert(aPath);
     }
     de = ::readdir(direntries);
   }






More information about the llvm-commits mailing list