Workaround dir removal on current dir on windows

This commit is contained in:
vit9696 2018-11-12 14:49:35 +03:00
parent 76ff756598
commit 2201a9b10c

View File

@ -37,11 +37,15 @@ static inline bool changeDirectory(const UString & dir) {
}
static inline void removeDirectory(const UString & dir) {
_rmdir(dir.toLocal8Bit());
int r = _rmdir(dir.toLocal8Bit());
// Hack: unlike *nix, Windows does not permit deleting current directories.
if (r < 0 && errno == EACCES && changeDirectory(dir + UString("/../"))) {
_rmdir(dir.toLocal8Bit());
}
}
static inline UString getAbsPath(const UString & path) {
char abs[1024] = {};
char abs[_MAX_PATH] = {};
if (_fullpath(abs, path.toLocal8Bit(), sizeof(abs)))
return UString(abs);
return path;