From edb543657aef8b5c9e96c006479102b2895b36ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C8=9Bca=20Dumitru?= Date: Sun, 21 Feb 2021 02:54:37 +0200 Subject: [PATCH] mv: Use Core::File::copy_file_or_directory --- Userland/Utilities/mv.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Userland/Utilities/mv.cpp b/Userland/Utilities/mv.cpp index 67d238cbe2..2e7973f84f 100644 --- a/Userland/Utilities/mv.cpp +++ b/Userland/Utilities/mv.cpp @@ -24,14 +24,12 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "cp.h" #include #include #include -#include +#include #include #include -#include int main(int argc, char** argv) { @@ -88,11 +86,11 @@ int main(int argc, char** argv) rc = rename(old_path, new_path); if (rc < 0) { if (errno == EXDEV) { - bool recursion_allowed = true; - bool link = false; - bool ok = copy_file_or_directory(old_path, new_path, recursion_allowed, link); - if (!ok) + auto result = Core::File::copy_file_or_directory(new_path, old_path, Core::File::RecursionMode::Allowed, Core::File::LinkMode::Disallowed, Core::File::AddDuplicateFileMarker::No); + if (result.is_error()) { + warnln("mv: could not move '{}': {}", old_path, result.error().error_code); return 1; + } rc = unlink(old_path); if (rc < 0) fprintf(stderr, "mv: unlink '%s': %s\n", old_path, strerror(errno));