Commit graph

21 commits

Author SHA1 Message Date
implicitfield de9fa25e11 cksum: Use the POSIX cksum algorithm rather than vanilla CRC32 2024-01-18 18:01:26 +03:30
Kemal Zebari b7dbdb4cd2 cksum: Print checksums as decimal rather than hexadecimal
POSIX and the implementations I see expect checksum to be printed
just as an unsigned integer.
2024-01-15 23:08:28 -07:00
Kemal Zebari 09a053a723 cksum: Handle edge case when no file operands are given when printing
Given no file operands, POSIX wants us to read from stdin as well
as omit "the pathname and its leading <space>" when printing.
2024-01-15 23:08:28 -07:00
Kemal Zebari 5d07c56d0d cksum: Decouple printing logic from checksum construction
This is to avoid duplicating the printing logic and so that we can
have an alternative way of printing the result (i.e. for the next
commit that will print without a pathname if no file operands were
provided). This also has us avoid the algorithm checks in the for
loop.
2024-01-15 23:08:28 -07:00
Sam Atkins 739e657ad0 cksum: Stop using DeprecatedString
This has the side-effect of making the algorithm name case-sensitive,
but there doesn't seem to be an especially good reason to support that.
On the other hand, converting an AK::String to lowercase would require
linking LibUnicode.
2023-04-22 07:17:08 +02: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
Ali Mohammad Pur 500044906d LibCore+Everywhere: Remove ArgsParser::add*(char const*&)
This is not guaranteed to always work correctly as ArgsParser deals in
StringViews and might have a non-properly-null-terminated string as a
value. As a bonus, using StringView (and DeprecatedString where
necessary) leads to nicer looking code too :^)
2023-03-01 10:47:19 +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
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 c279fd1097 cksum: Manually count file size instead of using stat()
`stat()` doesn't work for stdin, but this does.
2022-11-19 17:00:10 +00:00
Sam Atkins 83366e2b2e cksum: Port to Core::Stream 2022-11-19 17:00:10 +00: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
Kenneth Myhra 6e066bf1cd cksum: Port to LibMain :^) 2021-12-11 15:10:42 -08:00
Andreas Kling a7f1f1c34b LibCore: Use ErrorOr<T> for Core::File::open() 2021-11-08 00:35:27 +01:00
LuK1337 feacf774fb cksum: Print argv[0] on failed read
Forgot to do it in c5df5e5.
2021-08-01 19:26:57 +04:30
LuK1337 cf4bd4e4c9 cksum: Display adler32/crc32 sums as hex numbers
This basically follows what `crc32` and `xrdadler32` does on Linux
distros.
2021-08-01 13:02:16 +02:00
LuK1337 c5df5e504c cksum: Don't read the entire input file in memory
Same as `checksum`, in some cases we just can't load whole file into
memory.
2021-08-01 13:02:16 +02: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
Brendan Coles 0252563a4e Utilities: Add cksum 2021-04-24 11:53:55 +02:00