fix, do not remove non-empty directory

This commit is contained in:
Peter Hatina 2013-11-07 09:24:54 +01:00
parent a8c2902fca
commit 9cd94670d1
2 changed files with 3 additions and 0 deletions

View File

@ -310,6 +310,8 @@ int MTPDevice::dirRemove(const std::string &path)
logerr("No such directory '", path, "' to remove.\n");
return -ENOENT;
}
if (!dir_to_remove->isEmpty())
return -ENOTEMPTY;
criticalEnter();
int rval = LIBMTP_Delete_Object(m_device, dir_to_remove->id());
criticalLeave();

View File

@ -52,6 +52,7 @@ public:
const TypeFile *file(const std::string &name) const;
std::set<TypeDir> dirs() const { return m_dirs; }
std::set<TypeFile> files() const { return m_files; }
bool isEmpty() const { return m_dirs.empty() && m_files.empty(); }
LIBMTP_folder_t *toLIBMTPFolder() const;
TypeDir &operator =(const TypeDir &rhs);