mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibFileSystem: Add a helper to get the file size from fstat
This commit is contained in:
parent
896f213c6f
commit
a70d79ff98
Notes:
sideshowbarker
2024-07-18 08:59:31 +09:00
Author: https://github.com/implicitfield Commit: https://github.com/SerenityOS/serenity/commit/a70d79ff98 Pull-request: https://github.com/SerenityOS/serenity/pull/22810 Reviewed-by: https://github.com/ADKaster ✅
2 changed files with 7 additions and 0 deletions
|
@ -356,6 +356,12 @@ ErrorOr<off_t> size_from_stat(StringView path)
|
|||
return st.st_size;
|
||||
}
|
||||
|
||||
ErrorOr<off_t> size_from_fstat(int fd)
|
||||
{
|
||||
auto st = TRY(Core::System::fstat(fd));
|
||||
return st.st_size;
|
||||
}
|
||||
|
||||
bool can_delete_or_move(StringView path)
|
||||
{
|
||||
VERIFY(!path.is_empty());
|
||||
|
|
|
@ -72,6 +72,7 @@ ErrorOr<void> copy_file_or_directory(StringView destination_path, StringView sou
|
|||
ErrorOr<void> move_file(StringView destination_path, StringView source_path, PreserveMode = PreserveMode::Nothing);
|
||||
ErrorOr<void> remove(StringView path, RecursionMode);
|
||||
ErrorOr<off_t> size_from_stat(StringView path);
|
||||
ErrorOr<off_t> size_from_fstat(int fd);
|
||||
bool can_delete_or_move(StringView path);
|
||||
|
||||
ErrorOr<ByteString> read_link(StringView link_path);
|
||||
|
|
Loading…
Reference in a new issue