diff --git a/Userland/Libraries/LibFileSystem/FileSystem.cpp b/Userland/Libraries/LibFileSystem/FileSystem.cpp index a931eea9df..f6b5767da6 100644 --- a/Userland/Libraries/LibFileSystem/FileSystem.cpp +++ b/Userland/Libraries/LibFileSystem/FileSystem.cpp @@ -356,6 +356,12 @@ ErrorOr size_from_stat(StringView path) return st.st_size; } +ErrorOr 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()); diff --git a/Userland/Libraries/LibFileSystem/FileSystem.h b/Userland/Libraries/LibFileSystem/FileSystem.h index b520986ed2..400f07b09d 100644 --- a/Userland/Libraries/LibFileSystem/FileSystem.h +++ b/Userland/Libraries/LibFileSystem/FileSystem.h @@ -72,6 +72,7 @@ ErrorOr copy_file_or_directory(StringView destination_path, StringView sou ErrorOr move_file(StringView destination_path, StringView source_path, PreserveMode = PreserveMode::Nothing); ErrorOr remove(StringView path, RecursionMode); ErrorOr size_from_stat(StringView path); +ErrorOr size_from_fstat(int fd); bool can_delete_or_move(StringView path); ErrorOr read_link(StringView link_path);