Commit graph

23 commits

Author SHA1 Message Date
Tim Ledbetter
679fe00d10 LibCore+Utilities: Replace ElapsedTimer precise flag with an enum
Previously, `true` was passed into the ElapsedTimer constructor if a
precise timer was required. We now use an enum to more explicitly
specify whether we would like a precise or a coarse timer.
2024-02-26 16:12:20 -07:00
Sam Atkins
388856dc7e AK+Userland: Return String from human_readable_size() functions 2024-01-25 09:07:32 +01:00
Shannon Booth
e2e7c4d574 Everywhere: Use to_number<T> instead of to_{int,uint,float,double}
In a bunch of cases, this actually ends up simplifying the code as
to_number will handle something such as:

```
Optional<I> opt;
if constexpr (IsSigned<I>)
    opt = view.to_int<I>();
else
    opt = view.to_uint<I>();
```

For us.

The main goal here however is to have a single generic number conversion
API between all of the String classes.
2023-12-23 20:41:07 +01:00
Ali Mohammad Pur
5e1499d104 Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).

This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
2023-12-17 18:25:10 +03:30
Karol Kosek
c0be5bc070 dd: Print elapsed time and write speed after copying 2023-06-07 00:45:26 +02:00
Karol Kosek
4020892945 dd: Make status=noxfer still print some statistics 2023-06-07 00:45:26 +02:00
Karol Kosek
2f6c99dce5 dd: Show statistics also after receiving an interrupt signal 2023-06-07 00:45:26 +02:00
Sam Atkins
0f95ff64ed Utilities: Replace ctype.h usage with AK/CharacterTypes.h 2023-04-22 07:17:08 +02:00
Linus Groh
57dc179b1f Everywhere: Rename to_{string => deprecated_string}() where applicable
This will make it easier to support both string types at the same time
while we convert code, and tracking down remaining uses.

One big exception is Value::to_string() in LibJS, where the name is
dictated by the ToString AO.
2022-12-06 08:54:33 +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
demostanis
3e8b5ac920 AK+Everywhere: Turn bool keep_empty to an enum in split* functions 2022-10-24 23:29:18 +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
Idan Horowitz
086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
Kenneth Myhra
65f4d868e5 dd: Port to LibMain :^) 2021-12-11 15:10:42 -08:00
Dhruv Maroo
30af999431
Utilities: Allow filenames containing '=' in dd (#8766) 2021-07-15 18:36:46 +04:30
Linus Groh
f5c35fccca Userland: Replace most printf-style APIs with AK::Format APIs :^) 2021-06-01 21:30:16 +01:00
Linus Groh
1eb048bed0 Userland: Remove a bunch of unused includes
As reported by CLion.
2021-05-31 18:01:53 +01:00
Marcus Nilsson
c906987651 Utilites: Make dd truncate output file
Make dd truncate the output file as Gnu-dd does by default.
Fixes #7497
2021-05-27 15:19:06 +02:00
bleusakura
87de32df59
dd: Add ability to use k, M, & G suffixes for block sizes 2021-05-08 10:03:31 +01:00
Gunnar Beutner
605848787b Utilities: Specify mode argument when creating files with dd
When using open() with the O_CREAT flag we must specify the mode
argument. Otherwise we'll incorrectly set the new file's mode
to whatever is left on the stack:

courage:~ $ dd if=/dev/zero of=test count=1
1+0 blocks in
1+0 blocks out
512 bytes copied.
courage:~ $ ls -l test
--w-r-x---   1    anon   users        512   2021-05-08 01:29:52  test
courage:~ $

This also specifies the mode argument when opening files for
reading. This however is harmless because in those cases the argument
is ignored.

fixes #6923
2021-05-08 09:56:00 +02:00
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
Linus Groh
2b0c361d04 Everywhere: Fix a bunch of typos 2021-04-18 10:30:03 +02:00
g0mb4
e64a42dd50 Utilites: Add dd
This implementation of dd supports reading/writing/skipping/seeking
in terms of blocks. You can set the size of the block as well.
2021-03-29 11:02:02 +02:00