diff options
author | Mițca Dumitru <dumitru0mitca@gmail.com> | 2021-02-21 02:54:37 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-02-21 18:14:29 +0100 |
commit | edb543657aef8b5c9e96c006479102b2895b36ae (patch) | |
tree | e040732692e66e7f0b0d44142b713573115fbebd /Userland | |
parent | 3f88fd81d105cce5ea4a0ab612027f3c3f91cde5 (diff) | |
download | serenity-edb543657aef8b5c9e96c006479102b2895b36ae.zip |
mv: Use Core::File::copy_file_or_directory
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Utilities/mv.cpp | 12 |
1 files 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 <AK/LexicalPath.h> #include <AK/String.h> #include <LibCore/ArgsParser.h> -#include <errno.h> +#include <LibCore/File.h> #include <stdio.h> #include <sys/stat.h> -#include <unistd.h> 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)); |