Commit graph

42 commits

Author SHA1 Message Date
Lucas CHOLLET
496b7ffb2b LibGfx: Move all image loaders and writers to a subdirectory 2023-03-21 22:39:25 +01:00
kleines Filmröllchen
9ff01723ba Userland: Use more common WAV MIME type
There is no official IANA MIME type for WAV (see
https://www.iana.org/assignments/media-types/media-types.xhtml#audio),
so this will always be subjective. While
https://www.rfc-editor.org/rfc/rfc2361 suggests audio/vnd.wave, we use
audio/wav since that seems to be most common across the internet.
2023-03-17 22:20:16 +00:00
kleines Filmröllchen
0563048949 file: Read more metadata from audio files
We can always read the basic format information (sample rate, bit depth,
etc.), but we will also print artist, album, and title if available in
the metadata.
2023-03-13 12:35:17 -04:00
Tim Schumacher
d5871f5717 AK: Rename Stream::{read,write} to Stream::{read_some,write_some}
Similar to POSIX read, the basic read and write functions of AK::Stream
do not have a lower limit of how much data they read or write (apart
from "none at all").

Rename the functions to "read some [data]" and "write some [data]" (with
"data" being omitted, since everything here is reading and writing data)
to make them sufficiently distinct from the functions that ensure to
use the entire buffer (which should be the go-to function for most
usages).

No functional changes, just a lot of new FIXMEs.
2023-03-13 15:16:20 +00:00
kleines Filmröllchen
61bb9103c2 Base+Userland: Add support for QOA files everywhere
This adds MIME type sniffing,
`file` support,
LaunchServer support to open QOA in SoundPlayer,
and audio icons
2023-03-10 04:07:14 -07:00
Nico Weber
a81e1a8c4f file: Use StringView instead of DeprecatedString for paths 2023-02-27 15:18:55 +01:00
Nico Weber
4193e53f62 file: Use StringView instead of DeprecatedString for description 2023-02-27 15:18:55 +01:00
Nico Weber
f989d2bb1f file: Use StringView instead of DeprecatedString for mime types 2023-02-27 15:18:55 +01:00
Nico Weber
9f5343e29e file: Remove unnecessary DeprecatedString ctor call
path is already a DeprecatedString.
2023-02-27 15:18:55 +01:00
Nico Weber
5d5f9f52a0 Utilities: Make file print more information for animated images 2023-02-27 13:29:57 +01:00
Nico Weber
f5063fe7ec file: Add a description for the image/webp mime type 2023-02-24 19:44:20 +01:00
Tim Schumacher
874c7bba28 LibCore: Remove Stream.h 2023-02-13 00:50:07 +00:00
Tim Schumacher
606a3982f3 LibCore: Move Stream-based file into the Core namespace 2023-02-13 00:50:07 +00:00
Tim Schumacher
0245614a4f LibCore: Remove FileStream 2023-01-20 20:50:42 +00:00
Liav A
6e6999ce57 LibGfx: Re-work the abstractions of sending image for decoding over IPC
Originally I simply thought that passing file paths is quite OK, but as
Linus pointed to, it turned out that passing file paths to ensure some
files are able to be decoded is awkward because it does not work with
images being served over HTTP.

Therefore, ideally we should just use the MIME type as an optional
argument  to ensure that we can always fallback to use that in case
sniffing for the correct image type has failed so we can still detect
files like with the TGA format, which has no magic bytes.
2023-01-20 15:13:31 +00:00
Liav A
649f78d0a4 LibGfx+Ladybird+Userland: Don't sniff for TGA images with only raw bytes
Because TGA images don't have magic bytes as a signature to be detected,
instead assume a sequence of ReadonlyBytes is a possible TGA image only
if we are given a path so we could check the extension of the file and
see if it's a TGA image.

When we know the path of the file being loaded, we will try to first
check its extension, and only if there's no match to a known decoder,
based on simple extension lookup, then we would probe for other formats
as usual with the normal sniffing method.
2023-01-18 21:48:35 +01:00
Linus Groh
6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
2022-12-06 08:54:33 +01:00
Sam Atkins
813fc10aae file: Port to Core::Stream
Some nicer way of dealing with `stat` would be good. :thonk:
2022-11-19 17:00:10 +00:00
kleines Filmröllchen
e52a7663ce Utilities/file: Handle all supported audio MIME types 2022-08-16 13:58:51 +01:00
sin-ack
3f3f45580a Everywhere: Add sv suffix to strings relying on StringView(char const*)
Each of these strings would previously rely on StringView's char const*
constructor overload, which would call __builtin_strlen on the string.
Since we now have operator ""sv, we can replace these with much simpler
versions. This opens the door to being able to remove
StringView(char const*).

No functional changes.
2022-07-12 23:11:35 +02:00
Sam Atkins
f0aba519c3 Utilities: Read positional arguments as Strings not char*s
This is a pretty trivial change so they're all batched together.
2022-04-11 21:09:42 +02:00
Idan Horowitz
086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
Idan Horowitz
cfb9f889ac LibELF: Accept Span instead of Pointer+Size in validate_program_headers 2022-01-13 22:40:25 +01:00
Idan Horowitz
3e959618c3 LibELF: Use StringBuilders instead of Strings for the interpreter path
This is required for the Kernel's usage of LibELF, since Strings do not
expose allocation failure.
2022-01-13 22:40:25 +01:00
Linus Groh
0717e484f6 file: Add description & image details for image/x-qoi 2021-12-21 13:27:27 +01:00
Kenneth Myhra
54f6829533 file: Port to LibMain 2021-12-16 02:10:47 -08:00
Andreas Kling
58fb3ebf66 LibCore+AK: Move MappedFile from AK to LibCore
MappedFile is strictly a userspace thing, so it doesn't belong in AK
(which is supposed to be user/kernel agnostic.)
2021-11-23 11:33:36 +01:00
Valtteri Koskivuori
a3b3800cd4 Userland: Teach the file utility more about ELF files
It now shows some useful at-a-glance information about ELF files, like
it does on other *nix systems.
2021-10-21 01:14:09 +02:00
Andreas Kling
d01b4327fa LibGfx: Improve ImageDecoder construction
Previously, ImageDecoder::create() would return a NonnullRefPtr and
could not "fail", although the returned decoder may be "invalid" which
you then had to check anyway.

The new interface looks like this:

    static RefPtr<Gfx::ImageDecoder> try_create(ReadonlyBytes);

This simplifies ImageDecoder since it no longer has to worry about its
validity. Client code gets slightly clearer as well.
2021-07-27 01:17:05 +02:00
Valtteri Koskivuori
c69ea44397 Userland: Teach the file utility that empty files also exist
Previously, empty files with no identifiable file type extension would
show up as `text/plain`. This fixes it up to show empty files as what
they really are - full of nothing.
2021-06-15 21:30:55 +02:00
Arjan Zuidema
c7bc1f59d8 file: Output directory when path is a directory
Before file would output 'text/html' when the path was a directory.
2021-05-27 13:18:23 +01:00
Valtteri Koskivuori
cb8d0c8d0d LibCore+Userland: Add 13 more detectable file types
This patch adds 13 new detectable file formats, which are as follows in
alphabetical order:
.blend, .isz, ext* filesystem, Lua bytecode, Matroska container, NES
ROM, .pdf, qcow image, .rtf, WebAssembly bytecode, Windows 3.1X/95
compressed archive and raw zlib stream

Some are a tad esoteric, but the more file types we detect, the more
useful this utility becomes! :^)
2021-05-24 18:55:56 +01:00
Valtteri Koskivuori
eb9a0ace28 LibCore+Userland: Add two more detectable formats
Second batch of detectable formats, this time with verious offsets, as
enabled by the previous commit.
This adds tar, and the three signature variants for iso-9660 image
files.
2021-05-18 19:57:53 +01:00
Valtteri Koskivuori
105bbc457d LibCore+Userland: Add 5 more detectable filetypes
This adds gzip, sqlite, 7-Zip, flac and midi.
2021-05-18 19:57:53 +01:00
Ali Mohammad Pur
a91a49337c LibCore+Everywhere: Move OpenMode out of IODevice
...and make it an enum class so people don't omit "OpenMode".
2021-05-12 11:00:45 +01:00
Idan Horowitz
284730c002 Utilities: Use GzipDecompressor::describe_header for gzip descriptions 2021-05-07 23:22:07 +02:00
Linus Groh
e37d9eabb1 file: Clean up mime type enumeration macro
- Improve naming
- Order alphabetically
- Remove duplicates
2021-05-07 15:43:23 +01:00
Linus Groh
2ddd2d0866 file: Remove unused static description strings 2021-05-07 15:43:23 +01:00
Linus Groh
d7446e05db file: Don't exit immediately after file open error
Instead just remember that a file failed to open, carry on and return 1
at the end.
2021-05-07 15:43:23 +01:00
Linus Groh
85a7dae391 file: Remove redundant value_or({}) 2021-05-07 15:43:23 +01:00
Linus Groh
a9fcdc767e file: Avoid some unnecessary string copies 2021-05-07 15:43:23 +01:00
Valtteri Koskivuori
8b2706e5bb Userland: Implement a file utility
This unix classic attempts to classify and identify information about
given files based on various heuristics. In this case, we're relying on
the Core::MimeData detector for file type and LibGfx::ImageDecoder for
additional metadata if the given file is an image.
It's very simple for now, but adding new detectors should be quite easy.
2021-05-07 11:46:53 +01:00