1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 08:04:57 +00:00

usermod: Prefer FileSystem over DeprecatedFile

This commit is contained in:
Ben Wiederhake 2023-05-13 13:34:52 +02:00 committed by Jelle Raaijmakers
parent 54b3f90e47
commit c2d26ec541
2 changed files with 7 additions and 6 deletions

View file

@ -6,8 +6,8 @@
#include <LibCore/Account.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/DeprecatedFile.h>
#include <LibCore/System.h>
#include <LibFileSystem/FileSystem.h>
#include <LibMain/Main.h>
#include <pwd.h>
#include <stdio.h>
@ -103,11 +103,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto maybe_error = Core::System::rename(target_account.home_directory(), new_home_directory);
if (maybe_error.is_error()) {
if (maybe_error.error().code() == EXDEV) {
auto result = Core::DeprecatedFile::copy_file_or_directory(
new_home_directory, target_account.home_directory().characters(),
Core::DeprecatedFile::RecursionMode::Allowed,
Core::DeprecatedFile::LinkMode::Disallowed,
Core::DeprecatedFile::AddDuplicateFileMarker::No);
auto result = FileSystem::copy_file_or_directory(
new_home_directory, target_account.home_directory(),
FileSystem::RecursionMode::Allowed,
FileSystem::LinkMode::Disallowed,
FileSystem::AddDuplicateFileMarker::No);
if (result.is_error()) {
warnln("usermod: could not move directory {} : {}", target_account.home_directory().characters(), static_cast<Error const&>(result.error()));