mirror of https://github.com/stella-emu/stella.git
Minor 'const' updates to POSIX classes.
This commit is contained in:
parent
0c1eaa5b23
commit
c3ef18987b
|
@ -37,7 +37,7 @@ FilesystemNodePOSIX::FilesystemNodePOSIX(const string& path, bool verify)
|
||||||
// Expand '~' to the HOME environment variable
|
// Expand '~' to the HOME environment variable
|
||||||
if(_path[0] == '~')
|
if(_path[0] == '~')
|
||||||
{
|
{
|
||||||
string home = BSPF::getenv("HOME");
|
const string& home = BSPF::getenv("HOME");
|
||||||
if(home != EmptyString)
|
if(home != EmptyString)
|
||||||
_path.replace(0, 1, home);
|
_path.replace(0, 1, home);
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ void FilesystemNodePOSIX::setFlags()
|
||||||
string FilesystemNodePOSIX::getShortPath() const
|
string FilesystemNodePOSIX::getShortPath() const
|
||||||
{
|
{
|
||||||
// If the path starts with the home directory, replace it with '~'
|
// If the path starts with the home directory, replace it with '~'
|
||||||
string home = BSPF::getenv("HOME");
|
const string& home = BSPF::getenv("HOME");
|
||||||
if(home != EmptyString && BSPF::startsWithIgnoreCase(_path, home))
|
if(home != EmptyString && BSPF::startsWithIgnoreCase(_path, home))
|
||||||
{
|
{
|
||||||
string path = "~";
|
string path = "~";
|
||||||
|
@ -106,7 +106,7 @@ bool FilesystemNodePOSIX::getChildren(AbstractFSList& myList, ListMode mode) con
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Loop over dir entries using readdir
|
// Loop over dir entries using readdir
|
||||||
struct dirent* dp;
|
struct dirent* dp = nullptr;
|
||||||
while ((dp = readdir(dirp)) != nullptr)
|
while ((dp = readdir(dirp)) != nullptr)
|
||||||
{
|
{
|
||||||
// Ignore all hidden files
|
// Ignore all hidden files
|
||||||
|
|
|
@ -104,14 +104,14 @@ StringList SerialPortUNIX::portNames()
|
||||||
|
|
||||||
// Check if port is valid; for now that means if it can be opened
|
// Check if port is valid; for now that means if it can be opened
|
||||||
// Eventually we may extend this to do more intensive checks
|
// Eventually we may extend this to do more intensive checks
|
||||||
auto isPortValid = [](const string& port) {
|
const auto isPortValid = [](const string& port) {
|
||||||
int handle = open(port.c_str(), O_RDWR | O_NOCTTY | O_NONBLOCK);
|
int handle = open(port.c_str(), O_RDWR | O_NOCTTY | O_NONBLOCK);
|
||||||
if(handle > 0) close(handle);
|
if(handle > 0) close(handle);
|
||||||
return handle > 0;
|
return handle > 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Get all possible devices in the '/dev' directory
|
// Get all possible devices in the '/dev' directory
|
||||||
FilesystemNode::NameFilter filter = [](const FilesystemNode& node) {
|
const FilesystemNode::NameFilter filter = [](const FilesystemNode& node) {
|
||||||
return BSPF::startsWithIgnoreCase(node.getPath(), "/dev/ttyACM") ||
|
return BSPF::startsWithIgnoreCase(node.getPath(), "/dev/ttyACM") ||
|
||||||
BSPF::startsWithIgnoreCase(node.getPath(), "/dev/ttyUSB");
|
BSPF::startsWithIgnoreCase(node.getPath(), "/dev/ttyUSB");
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue