mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 23:55:38 +00:00
Added a function to delete directories.
This commit is contained in:
parent
7ab7dcc7c6
commit
c63fc39e8d
|
@ -505,7 +505,7 @@ namespace Utils
|
|||
std::string removeCommonPath(const std::string& _path,
|
||||
const std::string& _common, bool& _contains)
|
||||
{
|
||||
std::string path = getGenericPath(_path);
|
||||
std::string path = getGenericPath(_path);
|
||||
std::string common = isDirectory(_common) ?
|
||||
getGenericPath(_common) : getParent(_common);
|
||||
|
||||
|
@ -676,6 +676,25 @@ namespace Utils
|
|||
#endif
|
||||
}
|
||||
|
||||
bool removeDirectory(const std::string& path)
|
||||
{
|
||||
if (getDirContent(path).size() != 0) {
|
||||
LOG(LogError) << "Couldn't delete directory as it's not empty";
|
||||
LOG(LogError) << path;
|
||||
return false;
|
||||
}
|
||||
#if defined(_WIN64)
|
||||
if (_wrmdir(Utils::String::stringToWideString(path).c_str()) == 0) {
|
||||
#else
|
||||
if (rmdir(path.c_str()) != 0) {
|
||||
#endif
|
||||
LOG(LogError) << "Couldn't delete directory, permission problems?";
|
||||
LOG(LogError) << path;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool createDirectory(const std::string& _path)
|
||||
{
|
||||
std::string path = getGenericPath(_path);
|
||||
|
|
|
@ -53,6 +53,7 @@ namespace Utils
|
|||
bool renameFile(const std::string& _source_path,
|
||||
const std::string& _destination_path, bool _overwrite);
|
||||
bool removeFile(const std::string& _path);
|
||||
bool removeDirectory(const std::string& path);
|
||||
|
||||
bool createDirectory(const std::string& _path);
|
||||
bool exists(const std::string& _path);
|
||||
|
|
Loading…
Reference in a new issue