summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorValtteri Koskivuori <vkoskiv@gmail.com>2021-05-18 20:11:10 +0300
committerLinus Groh <mail@linusgroh.de>2021-05-18 19:57:53 +0100
commit105bbc457d9f99bd692db5335cdf146ccc0803fb (patch)
tree94769c767911c58af3bae6cbc5d6dd8197676e94 /Userland
parent2f49241296eb4487729e4f8fafdb70d42abfc661 (diff)
downloadserenity-105bbc457d9f99bd692db5335cdf146ccc0803fb.zip
LibCore+Userland: Add 5 more detectable filetypes
This adds gzip, sqlite, 7-Zip, flac and midi.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibCore/MimeData.cpp36
-rw-r--r--Userland/Utilities/file.cpp28
2 files changed, 36 insertions, 28 deletions
diff --git a/Userland/Libraries/LibCore/MimeData.cpp b/Userland/Libraries/LibCore/MimeData.cpp
index 4641e597c5..08140a690d 100644
--- a/Userland/Libraries/LibCore/MimeData.cpp
+++ b/Userland/Libraries/LibCore/MimeData.cpp
@@ -85,22 +85,26 @@ String guess_mime_type_based_on_filename(const StringView& path)
return "text/plain";
}
-#define ENUMERATE_HEADER_CONTENTS \
- __ENUMERATE_MIME_TYPE_HEADER(bmp, "image/bmp", 2, 'B', 'M') \
- __ENUMERATE_MIME_TYPE_HEADER(bzip2, "application/x-bzip2", 3, 'B', 'Z', 'h') \
- __ENUMERATE_MIME_TYPE_HEADER(elf, "extra/elf", 4, 0x7F, 'E', 'L', 'F') \
- __ENUMERATE_MIME_TYPE_HEADER(gif_87, "image/gif", 6, 'G', 'I', 'F', '8', '7', 'a') \
- __ENUMERATE_MIME_TYPE_HEADER(gif_89, "image/gif", 6, 'G', 'I', 'F', '8', '9', 'a') \
- __ENUMERATE_MIME_TYPE_HEADER(gzip, "extra/gzip", 2, 0x1F, 0x8B) \
- __ENUMERATE_MIME_TYPE_HEADER(jpeg, "image/jpeg", 4, 0xFF, 0xD8, 0xFF, 0xDB) \
- __ENUMERATE_MIME_TYPE_HEADER(jpeg_huh, "image/jpeg", 4, 0xFF, 0xD8, 0xFF, 0xEE) \
- __ENUMERATE_MIME_TYPE_HEADER(jpeg_jfif, "image/jpeg", 12, 0xFF, 0xD8, 0xFF, 0xE0, 0x00, 0x10, 'J', 'F', 'I', 'F', 0x00, 0x01) \
- __ENUMERATE_MIME_TYPE_HEADER(pbm, "image/x-portable-bitmap", 3, 0x50, 0x31, 0x0A) \
- __ENUMERATE_MIME_TYPE_HEADER(pgm, "image/x-portable-graymap", 3, 0x50, 0x32, 0x0A) \
- __ENUMERATE_MIME_TYPE_HEADER(png, "image/png", 8, 0x89, 'P', 'N', 'G', 0x0D, 0x0A, 0x1A, 0x0A) \
- __ENUMERATE_MIME_TYPE_HEADER(ppm, "image/x-portable-pixmap", 3, 0x50, 0x33, 0x0A) \
- __ENUMERATE_MIME_TYPE_HEADER(shell, "text/x-shellscript", 10, '#', '!', '/', 'b', 'i', 'n', '/', 's', 'h', '\n') \
- __ENUMERATE_MIME_TYPE_HEADER(tiff, "image/tiff", 4, 'I', 'I', '*', 0x00) \
+#define ENUMERATE_HEADER_CONTENTS \
+ __ENUMERATE_MIME_TYPE_HEADER(bmp, "image/bmp", 2, 'B', 'M') \
+ __ENUMERATE_MIME_TYPE_HEADER(bzip2, "application/x-bzip2", 3, 'B', 'Z', 'h') \
+ __ENUMERATE_MIME_TYPE_HEADER(elf, "extra/elf", 4, 0x7F, 'E', 'L', 'F') \
+ __ENUMERATE_MIME_TYPE_HEADER(flac, "extra/flac", 4, 0x66, 0x4C, 0x61, 0x43) \
+ __ENUMERATE_MIME_TYPE_HEADER(gif_87, "image/gif", 6, 'G', 'I', 'F', '8', '7', 'a') \
+ __ENUMERATE_MIME_TYPE_HEADER(gif_89, "image/gif", 6, 'G', 'I', 'F', '8', '9', 'a') \
+ __ENUMERATE_MIME_TYPE_HEADER(gzip, "application/gzip", 2, 0x1F, 0x8B) \
+ __ENUMERATE_MIME_TYPE_HEADER(jpeg, "image/jpeg", 4, 0xFF, 0xD8, 0xFF, 0xDB) \
+ __ENUMERATE_MIME_TYPE_HEADER(jpeg_huh, "image/jpeg", 4, 0xFF, 0xD8, 0xFF, 0xEE) \
+ __ENUMERATE_MIME_TYPE_HEADER(jpeg_jfif, "image/jpeg", 12, 0xFF, 0xD8, 0xFF, 0xE0, 0x00, 0x10, 'J', 'F', 'I', 'F', 0x00, 0x01) \
+ __ENUMERATE_MIME_TYPE_HEADER(midi, "audio/midi", 4, 0x4D, 0x54, 0x68, 0x64) \
+ __ENUMERATE_MIME_TYPE_HEADER(pbm, "image/x-portable-bitmap", 3, 0x50, 0x31, 0x0A) \
+ __ENUMERATE_MIME_TYPE_HEADER(pgm, "image/x-portable-graymap", 3, 0x50, 0x32, 0x0A) \
+ __ENUMERATE_MIME_TYPE_HEADER(png, "image/png", 8, 0x89, 'P', 'N', 'G', 0x0D, 0x0A, 0x1A, 0x0A) \
+ __ENUMERATE_MIME_TYPE_HEADER(ppm, "image/x-portable-pixmap", 3, 0x50, 0x33, 0x0A) \
+ __ENUMERATE_MIME_TYPE_HEADER(sevenzip, "application/x-7z-compressed", 6, 0x37, 0x7A, 0xBC, 0xAF, 0x27, 0x1C) \
+ __ENUMERATE_MIME_TYPE_HEADER(shell, "text/x-shellscript", 10, '#', '!', '/', 'b', 'i', 'n', '/', 's', 'h', '\n') \
+ __ENUMERATE_MIME_TYPE_HEADER(sqlite, "extra/sqlite", 16, 'S', 'Q', 'L', 'i', 't', 'e', ' ', 'f', 'o', 'r', 'm', 'a', 't', ' ', '3', 0x00) \
+ __ENUMERATE_MIME_TYPE_HEADER(tiff, "image/tiff", 4, 'I', 'I', '*', 0x00) \
__ENUMERATE_MIME_TYPE_HEADER(tiff_bigendian, "image/tiff", 4, 'M', 'M', 0x00, '*')
#define __ENUMERATE_MIME_TYPE_HEADER(var_name, mime_type, pattern_size, ...) \
diff --git a/Userland/Utilities/file.cpp b/Userland/Utilities/file.cpp
index 023edb4e7d..27fd88e455 100644
--- a/Userland/Utilities/file.cpp
+++ b/Userland/Utilities/file.cpp
@@ -52,18 +52,22 @@ static Optional<String> gzip_details(String description, const String& path)
return String::formatted("{}, {}", description, gzip_details.value());
}
-#define ENUMERATE_MIME_TYPE_DESCRIPTIONS \
- __ENUMERATE_MIME_TYPE_DESCRIPTION("application/javascript", "JavaScript source", description_only) \
- __ENUMERATE_MIME_TYPE_DESCRIPTION("application/json", "JSON data", description_only) \
- __ENUMERATE_MIME_TYPE_DESCRIPTION("extra/gzip", "gzip compressed data", gzip_details) \
- __ENUMERATE_MIME_TYPE_DESCRIPTION("image/bmp", "BMP image data", image_details) \
- __ENUMERATE_MIME_TYPE_DESCRIPTION("image/gif", "GIF image data", image_details) \
- __ENUMERATE_MIME_TYPE_DESCRIPTION("image/jpeg", "JPEG image data", image_details) \
- __ENUMERATE_MIME_TYPE_DESCRIPTION("image/png", "PNG image data", image_details) \
- __ENUMERATE_MIME_TYPE_DESCRIPTION("image/x-portable-bitmap", "PBM image data", image_details) \
- __ENUMERATE_MIME_TYPE_DESCRIPTION("image/x-portable-graymap", "PGM image data", image_details) \
- __ENUMERATE_MIME_TYPE_DESCRIPTION("image/x-portable-pixmap", "PPM image data", image_details) \
- __ENUMERATE_MIME_TYPE_DESCRIPTION("text/markdown", "Markdown document", description_only) \
+#define ENUMERATE_MIME_TYPE_DESCRIPTIONS \
+ __ENUMERATE_MIME_TYPE_DESCRIPTION("application/gzip", "gzip compressed data", gzip_details) \
+ __ENUMERATE_MIME_TYPE_DESCRIPTION("application/javascript", "JavaScript source", description_only) \
+ __ENUMERATE_MIME_TYPE_DESCRIPTION("application/json", "JSON data", description_only) \
+ __ENUMERATE_MIME_TYPE_DESCRIPTION("application/x-7z-compressed", "7-Zip archive", description_only) \
+ __ENUMERATE_MIME_TYPE_DESCRIPTION("audio/midi", "MIDI sound", description_only) \
+ __ENUMERATE_MIME_TYPE_DESCRIPTION("extra/flac", "FLAC audio", description_only) \
+ __ENUMERATE_MIME_TYPE_DESCRIPTION("extra/sqlite", "sqlite database", description_only) \
+ __ENUMERATE_MIME_TYPE_DESCRIPTION("image/bmp", "BMP image data", image_details) \
+ __ENUMERATE_MIME_TYPE_DESCRIPTION("image/gif", "GIF image data", image_details) \
+ __ENUMERATE_MIME_TYPE_DESCRIPTION("image/jpeg", "JPEG image data", image_details) \
+ __ENUMERATE_MIME_TYPE_DESCRIPTION("image/png", "PNG image data", image_details) \
+ __ENUMERATE_MIME_TYPE_DESCRIPTION("image/x-portable-bitmap", "PBM image data", image_details) \
+ __ENUMERATE_MIME_TYPE_DESCRIPTION("image/x-portable-graymap", "PGM image data", image_details) \
+ __ENUMERATE_MIME_TYPE_DESCRIPTION("image/x-portable-pixmap", "PPM image data", image_details) \
+ __ENUMERATE_MIME_TYPE_DESCRIPTION("text/markdown", "Markdown document", description_only) \
__ENUMERATE_MIME_TYPE_DESCRIPTION("text/x-shellscript", "POSIX shell script text executable", description_only)
static Optional<String> get_description_from_mime_type(const String& mime, const String& path)