From 6e46d46ffafc913c3d4ccb5fc637066e6d558041 Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Wed, 12 Oct 2022 18:45:24 -0230 Subject: [PATCH] More cleanups to FSNodeWINDOWS. --- src/os/windows/FSNodeWINDOWS.cxx | 26 +++++++++++++------------- src/os/windows/FSNodeWINDOWS.hxx | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/os/windows/FSNodeWINDOWS.cxx b/src/os/windows/FSNodeWINDOWS.cxx index 6984e1da7..026abb1a8 100644 --- a/src/os/windows/FSNodeWINDOWS.cxx +++ b/src/os/windows/FSNodeWINDOWS.cxx @@ -59,8 +59,9 @@ void FSNodeWINDOWS::setFlags() _isFile = !_isDirectory;//((fileAttribs & FILE_ATTRIBUTE_NORMAL) != 0); // Add a trailing backslash, if necessary - if (_isDirectory && _path.length() > 0 && _path[_path.length()-1] != '\\') - _path += '\\'; + if (_isDirectory && _path.length() > 0 && + _path[_path.length()-1] != FSNode::PATH_SEPARATOR) + _path += FSNode::PATH_SEPARATOR; } _isPseudoRoot = false; } @@ -74,7 +75,8 @@ string FSNodeWINDOWS::getShortPath() const { string path = "~"; const char* offset = _path.c_str() + home.length(); - if(*offset != '\\') path += '\\'; + if(*offset != FSNode::PATH_SEPARATOR) + path += FSNode::PATH_SEPARATOR; path += offset; return path; } @@ -149,10 +151,10 @@ bool FSNodeWINDOWS::getChildren(AbstractFSList& myList, ListMode mode) const if(handle == INVALID_HANDLE_VALUE) return false; - addFile(myList, mode, _path.c_str(), &desc); + addFile(myList, mode, _path, desc); while(FindNextFile(handle, &desc)) - addFile(myList, mode, _path.c_str(), &desc); + addFile(myList, mode, _path, desc); FindClose(handle); } @@ -162,16 +164,16 @@ bool FSNodeWINDOWS::getChildren(AbstractFSList& myList, ListMode mode) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FSNodeWINDOWS::addFile(AbstractFSList& list, ListMode mode, - const char* base, const WIN32_FIND_DATA* find_data) + const string& base, const WIN32_FIND_DATA& find_data) { - const char* const asciiName = find_data->cFileName; + const char* const asciiName = find_data.cFileName; bool isDirectory = false, isFile = false; // Skip local directory (.) and parent (..) if (!strncmp(asciiName, ".", 1) || !strncmp(asciiName, "..", 2)) return; - isDirectory = static_cast(find_data->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY); + isDirectory = static_cast(find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY); isFile = !isDirectory;//(find_data->dwFileAttributes & FILE_ATTRIBUTE_NORMAL ? true : false); if ((isFile && mode == FSNode::ListMode::DirectoriesOnly) || @@ -185,7 +187,7 @@ void FSNodeWINDOWS::addFile(AbstractFSList& list, ListMode mode, entry._path = base; entry._path += asciiName; if (entry._isDirectory) - entry._path += "\\"; + entry._path += FSNode::PATH_SEPARATOR; entry._isPseudoRoot = false; list.emplace_back(make_shared(entry)); @@ -217,8 +219,7 @@ bool FSNodeWINDOWS::makeDir() setFlags(); return true; } - else - return false; + return false; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -229,6 +230,5 @@ bool FSNodeWINDOWS::rename(const string& newfile) setFlags(); return true; } - else - return false; + return false; } diff --git a/src/os/windows/FSNodeWINDOWS.hxx b/src/os/windows/FSNodeWINDOWS.hxx index 0ebe7566f..21534ef32 100644 --- a/src/os/windows/FSNodeWINDOWS.hxx +++ b/src/os/windows/FSNodeWINDOWS.hxx @@ -86,7 +86,7 @@ class FSNodeWINDOWS : public AbstractFSNode * @param find_data Describes a file that the FindFirstFile, FindFirstFileEx, or FindNextFile functions find. */ static void addFile(AbstractFSList& list, ListMode mode, - const char* base, const WIN32_FIND_DATA* find_data); + const string& base, const WIN32_FIND_DATA& find_data); private: string _displayName, _path;