return !path.empty();
}
-bool
-Path::isAbsolute(const char *NameStart, unsigned NameLen) {
- assert(NameStart);
- if (NameLen == 0)
- return false;
- return NameStart[0] == '/';
-}
-
Path
Path::GetTemporaryDirectory(std::string *ErrMsg) {
#if defined(HAVE_MKDTEMP)
return Path();
}
-bool Path::getMagicNumber(std::string &Magic, unsigned len) const {
- assert(len < 1024 && "Request for magic string too long");
- char Buf[1025];
- int fd = ::open(path.c_str(), O_RDONLY);
- if (fd < 0)
- return false;
- ssize_t bytes_read = ::read(fd, Buf, len);
- ::close(fd);
- if (ssize_t(len) != bytes_read)
- return false;
- Magic.assign(Buf, len);
- return true;
-}
-
bool
Path::exists() const {
return 0 == access(path.c_str(), F_OK );
return S_ISLNK(buf.st_mode);
}
-
-bool
-Path::canRead() const {
- return 0 == access(path.c_str(), R_OK);
-}
-
-bool
-Path::canWrite() const {
- return 0 == access(path.c_str(), W_OK);
-}
-
bool
Path::isRegularFile() const {
// Get the status so we can determine if it's a file or directory
return false;
}
-bool
-Path::canExecute() const {
- if (0 != access(path.c_str(), R_OK | X_OK ))
- return false;
- struct stat buf;
- if (0 != stat(path.c_str(), &buf))
- return false;
- if (!S_ISREG(buf.st_mode))
- return false;
- return true;
-}
-
const FileStatus *
PathWithStatus::getFileStatus(bool update, std::string *ErrStr) const {
if (!fsIsValid || update) {
status.mode = buf.st_mode;
status.user = buf.st_uid;
status.group = buf.st_gid;
- status.uniqueID = uint64_t(buf.st_ino);
status.isDir = S_ISDIR(buf.st_mode);
status.isFile = S_ISREG(buf.st_mode);
fsIsValid = true;