mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-11 18:20:43 +09:00
LibCore: Use ErrorOr<T> for Core::File::link_file()
This commit is contained in:
parent
0f5477c721
commit
b2170c11a4
Notes:
sideshowbarker
2024-07-18 01:24:08 +09:00
Author: https://github.com/awesomekling
Commit: b2170c11a4
2 changed files with 4 additions and 7 deletions
|
@ -498,7 +498,7 @@ Result<void, File::CopyError> File::copy_directory(String const& dst_path, Strin
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<void, OSError> File::link_file(String const& dst_path, String const& src_path)
|
ErrorOr<void> File::link_file(String const& dst_path, String const& src_path)
|
||||||
{
|
{
|
||||||
int duplicate_count = 0;
|
int duplicate_count = 0;
|
||||||
while (access(get_duplicate_name(dst_path, duplicate_count).characters(), F_OK) == 0) {
|
while (access(get_duplicate_name(dst_path, duplicate_count).characters(), F_OK) == 0) {
|
||||||
|
@ -507,11 +507,8 @@ Result<void, OSError> File::link_file(String const& dst_path, String const& src_
|
||||||
if (duplicate_count != 0) {
|
if (duplicate_count != 0) {
|
||||||
return link_file(get_duplicate_name(dst_path, duplicate_count), src_path);
|
return link_file(get_duplicate_name(dst_path, duplicate_count), src_path);
|
||||||
}
|
}
|
||||||
int rc = symlink(src_path.characters(), dst_path.characters());
|
if (symlink(src_path.characters(), dst_path.characters()) < 0)
|
||||||
if (rc < 0) {
|
return Error::from_errno(errno);
|
||||||
return OSError(errno);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ public:
|
||||||
|
|
||||||
static String real_path_for(String const& filename);
|
static String real_path_for(String const& filename);
|
||||||
static String read_link(String const& link_path);
|
static String read_link(String const& link_path);
|
||||||
static Result<void, OSError> link_file(String const& dst_path, String const& src_path);
|
static ErrorOr<void> link_file(String const& dst_path, String const& src_path);
|
||||||
|
|
||||||
struct RemoveError {
|
struct RemoveError {
|
||||||
String file;
|
String file;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue