edit removeFile to also handle Folders

pull/23/head
JuanJakobo 2021-02-22 16:50:56 +01:00
parent c03bb632f7
commit 7aaf79e2e7
1 changed files with 8 additions and 3 deletions

View File

@ -56,12 +56,11 @@ Item::Item(const string &xmlItem)
Util::decodeUrl(_title); Util::decodeUrl(_title);
} }
Item::Item(const string &localPath, FileState state) : _localPath(localPath), _state(state) Item::Item(const string &localPath, FileState state, Itemtype type) : _localPath(localPath), _state(state), _type(type)
{ {
_title = _localPath; _title = _localPath;
_title = _title.substr(_title.find_last_of("/") + 1, _title.length()); _title = _title.substr(_title.find_last_of("/") + 1, _title.length());
Util::decodeUrl(_title); Util::decodeUrl(_title);
_fileType = IFILE;
} }
void Item::open() const void Item::open() const
@ -102,10 +101,16 @@ void Item::open() const
bool Item::removeFile() bool Item::removeFile()
{ {
if (_type == Itemtype::IFOLDER)
{
string cmd = "rm -rf " + _localPath + "/";
system(cmd.c_str());
return true;
}
if (remove(_localPath.c_str()) != 0) if (remove(_localPath.c_str()) != 0)
return false; return false;
if (_state == FileState::ISYNCED) if (_state == FileState::ISYNCED || _state == FileState::IOUTSYNCED)
{ {
_state = FileState::ICLOUD; _state = FileState::ICLOUD;
} }