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
|
||||
if(_path[0] == '~')
|
||||
{
|
||||
string home = BSPF::getenv("HOME");
|
||||
const string& home = BSPF::getenv("HOME");
|
||||
if(home != EmptyString)
|
||||
_path.replace(0, 1, home);
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ void FilesystemNodePOSIX::setFlags()
|
|||
string FilesystemNodePOSIX::getShortPath() const
|
||||
{
|
||||
// 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))
|
||||
{
|
||||
string path = "~";
|
||||
|
@ -106,7 +106,7 @@ bool FilesystemNodePOSIX::getChildren(AbstractFSList& myList, ListMode mode) con
|
|||
return false;
|
||||
|
||||
// Loop over dir entries using readdir
|
||||
struct dirent* dp;
|
||||
struct dirent* dp = nullptr;
|
||||
while ((dp = readdir(dirp)) != nullptr)
|
||||
{
|
||||
// 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
|
||||
// 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);
|
||||
if(handle > 0) close(handle);
|
||||
return handle > 0;
|
||||
};
|
||||
|
||||
// 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") ||
|
||||
BSPF::startsWithIgnoreCase(node.getPath(), "/dev/ttyUSB");
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue