1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 04:47:35 +00:00

LibCore: Implement preserve flag for file/directory copy

This commit is contained in:
Jean-Baptiste Boric 2021-08-15 12:24:00 +02:00 committed by Andreas Kling
parent 91bcff2994
commit 8cc8d72619
2 changed files with 45 additions and 11 deletions

View file

@ -53,14 +53,19 @@ public:
No,
};
enum class PreserveMode {
Nothing,
PermissionsOwnershipTimestamps,
};
struct CopyError {
OSError error_code;
bool tried_recursing;
};
static Result<void, CopyError> copy_file(String const& dst_path, struct stat const& src_stat, File& source);
static Result<void, CopyError> copy_directory(String const& dst_path, String const& src_path, struct stat const& src_stat, LinkMode = LinkMode::Disallowed);
static Result<void, CopyError> copy_file_or_directory(String const& dst_path, String const& src_path, RecursionMode = RecursionMode::Allowed, LinkMode = LinkMode::Disallowed, AddDuplicateFileMarker = AddDuplicateFileMarker::Yes);
static Result<void, CopyError> copy_file(String const& dst_path, struct stat const& src_stat, File& source, PreserveMode = PreserveMode::Nothing);
static Result<void, CopyError> copy_directory(String const& dst_path, String const& src_path, struct stat const& src_stat, LinkMode = LinkMode::Disallowed, PreserveMode = PreserveMode::Nothing);
static Result<void, CopyError> copy_file_or_directory(String const& dst_path, String const& src_path, RecursionMode = RecursionMode::Allowed, LinkMode = LinkMode::Disallowed, AddDuplicateFileMarker = AddDuplicateFileMarker::Yes, PreserveMode = PreserveMode::Nothing);
static String real_path_for(String const& filename);
static String read_link(String const& link_path);