45BESFSFile::BESFSFile(
const string &fullPath) :
46 _dirName(
""), _fileName(
""), _baseName(
""), _extension(
"")
51BESFSFile::BESFSFile(
const string &dirName,
const string &fileName) :
52 _dirName(dirName), _fileName(fileName), _baseName(
""), _extension(
"")
57BESFSFile::BESFSFile(
const BESFSFile ©From) :
58 _dirName(copyFrom._dirName), _fileName(copyFrom._fileName), _baseName(copyFrom._baseName), _extension(
63BESFSFile::~BESFSFile()
67string BESFSFile::getDirName()
72string BESFSFile::getFileName()
77string BESFSFile::getBaseName()
82string BESFSFile::getExtension()
87string BESFSFile::getFullPath()
89 return _dirName +
"/" + _fileName;
92void BESFSFile::breakApart(
const string &fullPath)
94 string::size_type pos = fullPath.rfind(
"/");
95 if (pos != string::npos) {
96 _dirName = fullPath.substr(0, pos);
97 _fileName = fullPath.substr(pos + 1, fullPath.size() - pos);
101 _fileName = fullPath;
107void BESFSFile::breakExtension()
109 string::size_type pos = _fileName.rfind(
".");
110 if (pos != string::npos) {
111 _baseName = _fileName.substr(0, pos);
112 _extension = _fileName.substr(pos + 1, _fileName.size() - pos);
115 _baseName = _fileName;
119bool BESFSFile::exists(
string &reason)
122 if (!access(getFullPath().c_str(), F_OK)) {
126 char *err = strerror(errno);
131 reason +=
"Unknown error";
137bool BESFSFile::isReadable(
string &reason)
140 if (!access(getFullPath().c_str(), R_OK)) {
144 char *err = strerror(errno);
149 reason +=
"Unknown error";
155bool BESFSFile::isWritable(
string &reason)
158 if (!access(getFullPath().c_str(), W_OK)) {
162 char *err = strerror(errno);
167 reason +=
"Unknown error";
173bool BESFSFile::isExecutable(
string &reason)
176 if (!access(getFullPath().c_str(), X_OK)) {
180 char *err = strerror(errno);
185 reason +=
"Unknown error";
191bool BESFSFile::hasDotDot()
194 string fp = getFullPath();
195 if (fp.find(
"..") != string::npos) {