diff --git a/CMakeLists.txt b/CMakeLists.txt index 571035a..3f77b67 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,7 +70,7 @@ add_executable(ezremote_client add_self(ezremote_client) -add_pkg(ezremote_client ${CMAKE_SOURCE_DIR}/data "RMTC00001" "ezRemote Client" "01.37" 32 0) +add_pkg(ezremote_client ${CMAKE_SOURCE_DIR}/data "RMTC00001" "ezRemote Client" "01.38" 32 0) target_link_libraries(ezremote_client c diff --git a/source/actions.cpp b/source/actions.cpp index 28e953a..a733ea3 100644 --- a/source/actions.cpp +++ b/source/actions.cpp @@ -1470,6 +1470,16 @@ namespace Actions if (src.isDir) { int err; + if (!isCopy && !FS::FolderExists(dest)) + { + errno = 0; + int ret = rename(src.path, dest); + if (ret != 0 && errno != EXDEV && errno != EEXIST) + { + return 0; + } + } + std::vector entries = FS::ListDir(src.path, &err); FS::MkDirs(dest); for (int i = 0; i < entries.size(); i++) @@ -1484,9 +1494,11 @@ namespace Actions if (entries[i].isDir) { if (strcmp(entries[i].name, "..") == 0) + { + free(new_path); continue; + } - FS::MkDirs(new_path); ret = CopyOrMove(entries[i], new_path, isCopy); if (ret <= 0) { @@ -1510,6 +1522,11 @@ namespace Actions } free(new_path); } + + if (!isCopy && FS::FolderExists(src.path)) + { + FS::RmDir(src.path); + } } else { @@ -1551,7 +1568,6 @@ namespace Actions char new_dir[512]; sprintf(new_dir, "%s%s%s", local_directory, FS::hasEndSlash(local_directory) ? "" : "/", it->name); CopyOrMove(*it, new_dir, false); - FS::RmRecursive(it->path); } else { diff --git a/source/clients/myrient.cpp b/source/clients/myrient.cpp index cdef14d..9026c57 100644 --- a/source/clients/myrient.cpp +++ b/source/clients/myrient.cpp @@ -223,7 +223,10 @@ std::vector MyrientClient::ListDir(const std::string &path) } lxb_dom_collection_destroy(td_collection, true); - out.push_back(entry); + if (strcmp(entry.name, "..") != 0 && strcmp(entry.name, ".") != 0) + { + out.push_back(entry); + } } lxb_dom_collection_destroy(tr_collection, true); diff --git a/source/fs.cpp b/source/fs.cpp index f9d188f..ca358fc 100644 --- a/source/fs.cpp +++ b/source/fs.cpp @@ -50,7 +50,7 @@ namespace FS void RmDir(const std::string &path) { - remove(path.c_str()); + rmdir(path.c_str()); } int64_t GetSize(const std::string &path) @@ -85,6 +85,7 @@ namespace FS return 1; return 0; } + void Rename(const std::string &from, const std::string &to) { int res = rename(from.c_str(), to.c_str()); @@ -269,6 +270,7 @@ namespace FS if (dirent == NULL) { closedir(fd); + fd = NULL; return out; } else @@ -344,6 +346,7 @@ namespace FS } } closedir(fd); + fd = NULL; return out; } @@ -549,11 +552,16 @@ namespace FS if (from.compare(to) == 0) return true; - bool res = Copy(from, to); - if (res) - Rm(from); - else - return res; + errno = 0; + int ret = rename(from.c_str(), to.c_str()); + if (ret != 0 && (errno == EXDEV || errno == EEXIST)) + { + bool res = Copy(from, to); + if (res) + Rm(from); + else + return res; + } return true; }