mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-22 23:24:59 +00:00
Implement functionality suggested from code review: getStatusInfo should
returnn false if the file doesn't exist rather than throw ane exception. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17809 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -239,8 +239,10 @@ Path::getLast() const {
|
|||||||
return path.substr(pos+1);
|
return path.substr(pos+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
bool
|
||||||
Path::getStatusInfo(StatusInfo& info) {
|
Path::getStatusInfo(StatusInfo& info) {
|
||||||
|
if (!isFile() || !readable())
|
||||||
|
return false;
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
if (0 != stat(path.c_str(), &buf)) {
|
if (0 != stat(path.c_str(), &buf)) {
|
||||||
ThrowErrno(std::string("Can't get status: ")+path);
|
ThrowErrno(std::string("Can't get status: ")+path);
|
||||||
@@ -253,6 +255,7 @@ Path::getStatusInfo(StatusInfo& info) {
|
|||||||
info.isDir = S_ISDIR(buf.st_mode);
|
info.isDir = S_ISDIR(buf.st_mode);
|
||||||
if (info.isDir && path[path.length()-1] != '/')
|
if (info.isDir && path[path.length()-1] != '/')
|
||||||
path += '/';
|
path += '/';
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@@ -239,8 +239,10 @@ Path::getLast() const {
|
|||||||
return path.substr(pos+1);
|
return path.substr(pos+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
bool
|
||||||
Path::getStatusInfo(StatusInfo& info) {
|
Path::getStatusInfo(StatusInfo& info) {
|
||||||
|
if (!isFile() || !readable())
|
||||||
|
return false;
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
if (0 != stat(path.c_str(), &buf)) {
|
if (0 != stat(path.c_str(), &buf)) {
|
||||||
ThrowErrno(std::string("Can't get status: ")+path);
|
ThrowErrno(std::string("Can't get status: ")+path);
|
||||||
@@ -253,6 +255,7 @@ Path::getStatusInfo(StatusInfo& info) {
|
|||||||
info.isDir = S_ISDIR(buf.st_mode);
|
info.isDir = S_ISDIR(buf.st_mode);
|
||||||
if (info.isDir && path[path.length()-1] != '/')
|
if (info.isDir && path[path.length()-1] != '/')
|
||||||
path += '/';
|
path += '/';
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
Reference in New Issue
Block a user