diff --git a/Userland/Utilities/file.cpp b/Userland/Utilities/file.cpp index e9e2414db7e..e35d6760893 100644 --- a/Userland/Utilities/file.cpp +++ b/Userland/Utilities/file.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include static Optional description_only(String description, [[maybe_unused]] const String& path) @@ -121,8 +122,17 @@ int main(int argc, char** argv) continue; } + struct stat file_stat; + if (lstat(path, &file_stat) < 0) { + perror("lstat"); + return 1; + } + + auto file_size_in_bytes = file_stat.st_size; if (file->is_directory()) { outln("{}: directory", path); + } else if (!file_size_in_bytes) { + outln("{}: empty", path); } else { // Read accounts for longest possible offset + signature we currently match against. auto bytes = file->read(0x9006);