More cleanups to FSNodeWINDOWS.

This commit is contained in:
Stephen Anthony 2022-10-15 19:54:51 -02:30
parent f05aeb3e46
commit 4302488754
2 changed files with 25 additions and 32 deletions

View File

@ -37,7 +37,7 @@ FSNodeWINDOWS::FSNodeWINDOWS(const string& p)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FSNodeWINDOWS::setFlags()
bool FSNodeWINDOWS::setFlags()
{
// Get absolute path
TCHAR buf[MAX_PATH];
@ -52,6 +52,7 @@ void FSNodeWINDOWS::setFlags()
if (fileAttribs == INVALID_FILE_ATTRIBUTES)
{
_isDirectory = _isFile = false;
return false;
}
else
{
@ -64,6 +65,8 @@ void FSNodeWINDOWS::setFlags()
_path += FSNode::PATH_SEPARATOR;
}
_isPseudoRoot = false;
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -114,8 +117,6 @@ AbstractFSNodePtr FSNodeWINDOWS::getParent() const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool FSNodeWINDOWS::getChildren(AbstractFSList& myList, ListMode mode) const
{
assert(_isDirectory);
if (_isPseudoRoot)
{
// Drives enumeration
@ -142,12 +143,7 @@ bool FSNodeWINDOWS::getChildren(AbstractFSList& myList, ListMode mode) const
{
// Files enumeration
WIN32_FIND_DATA desc;
HANDLE handle;
ostringstream searchPath;
searchPath << _path << "*";
handle = FindFirstFile(searchPath.str().c_str(), &desc);
HANDLE handle = FindFirstFile((_path + "*").c_str(), &desc);
if (handle == INVALID_HANDLE_VALUE)
return false;
@ -215,10 +211,8 @@ bool FSNodeWINDOWS::isWritable() const
bool FSNodeWINDOWS::makeDir()
{
if (!_isPseudoRoot && CreateDirectory(_path.c_str(), NULL) != 0)
{
setFlags();
return true;
}
return setFlags();
return false;
}
@ -226,9 +220,7 @@ bool FSNodeWINDOWS::makeDir()
bool FSNodeWINDOWS::rename(const string& newfile)
{
if (!_isPseudoRoot && MoveFile(_path.c_str(), newfile.c_str()) != 0)
{
setFlags();
return true;
}
return setFlags();
return false;
}

View File

@ -71,10 +71,11 @@ class FSNodeWINDOWS : public AbstractFSNode
private:
/**
* Tests and sets the _isValid and _isDirectory/_isFile flags,
* using the GetFileAttributes() function.
* Set the _isDirectory/_isFile/_size flags using GetFileAttributes().
*
* @return Success/failure of GetFileAttributes() function
*/
void setFlags();
bool setFlags();
/**
* Adds a single FSNodeWINDOWS to a given list.