Skip to content

Commit

Permalink
LibCore+Userland: Add more detectable types
Browse files Browse the repository at this point in the history
More binary format detectors and descriptions
  • Loading branch information
vkoskiv authored and linusg committed May 7, 2021
1 parent 8b2706e commit 00de3b5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Userland/Libraries/LibCore/MimeData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ String guess_mime_type_based_on_filename(const StringView& path)
return "text/markdown";
if (path.ends_with(".html", CaseSensitivity::CaseInsensitive) || path.ends_with(".htm", CaseSensitivity::CaseInsensitive))
return "text/html";
if (path.ends_with(".js", CaseSensitivity::CaseInsensitive))
return "application/javascript";
if (path.ends_with(".json", CaseSensitivity::CaseInsensitive))
return "application/json";
if (path.ends_with(".md", CaseSensitivity::CaseInsensitive))
return "text/markdown";
if (path.ends_with("/", CaseSensitivity::CaseInsensitive))
return "text/html";
if (path.ends_with(".csv", CaseSensitivity::CaseInsensitive))
Expand All @@ -93,7 +99,9 @@ String guess_mime_type_based_on_filename(const StringView& path)
__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(shell, "text/x-shellscript", 10, '#', '!', '/', 'b', 'i', 'n', '/', 's', 'h', '\n') \
__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, ...) \
static const u8 var_name##_arr[pattern_size] = { __VA_ARGS__ }; \
Expand Down

0 comments on commit 00de3b5

Please sign in to comment.