mirror of https://github.com/stella-emu/stella.git
Minor fixes to FSNodePOSIX.
This commit is contained in:
parent
25c882b4bd
commit
788c836130
src/os/unix
|
@ -89,7 +89,7 @@ string FSNodePOSIX::getShortPath() const
|
||||||
if (home != EmptyString && BSPF::startsWithIgnoreCase(_path, home))
|
if (home != EmptyString && BSPF::startsWithIgnoreCase(_path, home))
|
||||||
{
|
{
|
||||||
string path = "~";
|
string path = "~";
|
||||||
const char* offset = _path.c_str() + home.size();
|
const char* const offset = _path.c_str() + home.size();
|
||||||
if (*offset != FSNode::PATH_SEPARATOR)
|
if (*offset != FSNode::PATH_SEPARATOR)
|
||||||
path += FSNode::PATH_SEPARATOR;
|
path += FSNode::PATH_SEPARATOR;
|
||||||
path += offset;
|
path += offset;
|
||||||
|
@ -121,8 +121,8 @@ AbstractFSNodePtr FSNodePOSIX::getParent() const
|
||||||
if (_path == ROOT_DIR)
|
if (_path == ROOT_DIR)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
const char* start = _path.c_str();
|
const char* const start = _path.c_str();
|
||||||
const char* end = lastPathComponent(_path);
|
const char* const end = lastPathComponent(_path);
|
||||||
|
|
||||||
return make_unique<FSNodePOSIX>(string(start, static_cast<size_t>(end - start)));
|
return make_unique<FSNodePOSIX>(string(start, static_cast<size_t>(end - start)));
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,8 @@ bool FSNodePOSIX::getChildren(AbstractFSList& myList, ListMode mode) const
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
string newPath(_path);
|
string newPath(_path);
|
||||||
if (newPath.length() > 0 && newPath[newPath.length()-1] != FSNode::PATH_SEPARATOR)
|
if (newPath.length() > 0 &&
|
||||||
|
newPath[newPath.length()-1] != FSNode::PATH_SEPARATOR)
|
||||||
newPath += FSNode::PATH_SEPARATOR;
|
newPath += FSNode::PATH_SEPARATOR;
|
||||||
newPath += dp->d_name;
|
newPath += dp->d_name;
|
||||||
|
|
||||||
|
@ -162,7 +163,7 @@ bool FSNodePOSIX::getChildren(AbstractFSList& myList, ListMode mode) const
|
||||||
{
|
{
|
||||||
entry._isDirectory = (dp->d_type == DT_DIR);
|
entry._isDirectory = (dp->d_type == DT_DIR);
|
||||||
entry._isFile = (dp->d_type == DT_REG);
|
entry._isFile = (dp->d_type == DT_REG);
|
||||||
// entry._size will be calculated next time ::getSize() is called
|
// entry._size will be calculated first time ::getSize() is called
|
||||||
|
|
||||||
if (entry._isDirectory)
|
if (entry._isDirectory)
|
||||||
entry._path += FSNode::PATH_SEPARATOR;
|
entry._path += FSNode::PATH_SEPARATOR;
|
||||||
|
@ -178,7 +179,7 @@ bool FSNodePOSIX::getChildren(AbstractFSList& myList, ListMode mode) const
|
||||||
(mode == FSNode::ListMode::DirectoriesOnly && !entry._isDirectory))
|
(mode == FSNode::ListMode::DirectoriesOnly && !entry._isDirectory))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
myList.emplace_back(make_shared<FSNodePOSIX>(entry));
|
myList.emplace_back(make_unique<FSNodePOSIX>(entry));
|
||||||
}
|
}
|
||||||
closedir(dirp);
|
closedir(dirp);
|
||||||
|
|
||||||
|
@ -220,4 +221,4 @@ bool FSNodePOSIX::rename(const string& newfile)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
const char* FSNodePOSIX::ourHomeDir = std::getenv("HOME"); // NOLINT (not thread safe)
|
const char* const FSNodePOSIX::ourHomeDir = std::getenv("HOME"); // NOLINT (not thread safe)
|
||||||
|
|
|
@ -90,7 +90,7 @@ class FSNodePOSIX : public AbstractFSNode
|
||||||
bool _isFile{false}, _isDirectory{true};
|
bool _isFile{false}, _isDirectory{true};
|
||||||
mutable size_t _size{0};
|
mutable size_t _size{0};
|
||||||
|
|
||||||
static const char* ourHomeDir;
|
static const char* const ourHomeDir;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue