LibFileSystem: Add a method to query disk space stats

This returns the amount of free and total disk space for the partition
of a provided path.
This commit is contained in:
Timothy Flynn
2026-02-04 17:49:11 -05:00
committed by Tim Flynn
parent 49d24f1867
commit 551b82ae0b
Notes: github-actions[bot] 2026-02-13 15:22:48 +00:00
2 changed files with 42 additions and 5 deletions

View File

@@ -9,6 +9,7 @@
#include <AK/ByteString.h>
#include <AK/Error.h>
#include <AK/LexicalPath.h>
#include <AK/StringView.h>
#include <LibCore/File.h>
@@ -65,4 +66,10 @@ ErrorOr<off_t> size_from_stat(StringView path);
ErrorOr<off_t> size_from_fstat(int fd);
bool can_delete_or_move(StringView path);
struct DiskSpace {
u64 free_bytes { 0 };
u64 total_bytes { 0 };
};
ErrorOr<DiskSpace> compute_disk_space(LexicalPath const&);
}