summaryrefslogtreecommitdiff
path: root/lib/System/Unix
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2004-11-16 06:15:19 +0000
committerReid Spencer <rspencer@reidspencer.com>2004-11-16 06:15:19 +0000
commitb608a81a18dee7fbae18147f10af3fd1db31a5f4 (patch)
tree2ea2a497ffc3e894f8b0007da5740eb441cf63ab /lib/System/Unix
parent9bbba091396922093687d11a181e5886c42c5dfd (diff)
downloadllvm-b608a81a18dee7fbae18147f10af3fd1db31a5f4.tar.gz
llvm-b608a81a18dee7fbae18147f10af3fd1db31a5f4.tar.bz2
llvm-b608a81a18dee7fbae18147f10af3fd1db31a5f4.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17872 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System/Unix')
-rw-r--r--lib/System/Unix/Path.cpp11
-rw-r--r--lib/System/Unix/Path.inc11
2 files changed, 8 insertions, 14 deletions
diff --git a/lib/System/Unix/Path.cpp b/lib/System/Unix/Path.cpp
index d2ba0f9035..55ef6669ee 100644
--- a/lib/System/Unix/Path.cpp
+++ b/lib/System/Unix/Path.cpp
@@ -239,10 +239,8 @@ Path::getLast() const {
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 @@ Path::getStatusInfo(StatusInfo& info) {
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 @@ Path::getDirectoryContents(Vector& result) const {
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);
}
diff --git a/lib/System/Unix/Path.inc b/lib/System/Unix/Path.inc
index d2ba0f9035..55ef6669ee 100644
--- a/lib/System/Unix/Path.inc
+++ b/lib/System/Unix/Path.inc
@@ -239,10 +239,8 @@ Path::getLast() const {
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 @@ Path::getStatusInfo(StatusInfo& info) {
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 @@ Path::getDirectoryContents(Vector& result) const {
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);
}