void VfsCatalog::removeDir(const std::string& path) throw (DmException)
{
char *cwd = NULL, *rmd = NULL;
- std::string parentPath, name;
+ std::string parentPath, name, lpath;
if (vfsCheckPermissions(path, S_IWRITE))
vfsThrow(EACCES, "not enough permissions for '%s'", clientName.c_str());
vfsThrow(EACCES, "not enough permissions for '%s' to remove '%s'", clientName.c_str(), path.c_str());
}
+ lpath = getLocalPath(path);
+
// check if we are not removing current working directory
cwd = get_current_dir_name();
try {
- changeDir(path);
+ wrapCall(::chdir(lpath.c_str()));
rmd = get_current_dir_name();
if (strcmp(cwd, rmd) == 0) {
vfsThrow(EINVAL, "can not remove current working directory");
}
::chdir(cwd);
// OK, we can try to remove
- wrapCall(rmdir(getLocalPath(path).c_str()));
+ wrapCall(rmdir(lpath.c_str()));
} catch (...) {
if (cwd) ::chdir(cwd);
free(cwd);