Age | Commit message (Collapse) | Author |
|
This generally seems like a better name, especially if we somehow also
need a better name for "read the entire buffer, but not the entire file"
somewhere down the line.
|
|
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.
|
|
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 :^)
|
|
|
|
All of these conditions should make du just not report the file size
individually, but it should still count them into the grand total.
In the case of the `--threshold` option, this was actually implemented
incorrectly before, as it would report size 0 for files that did not
match the threshold.
|
|
This keeps us from repeatedly applying the block size calculation on
already processed values.
|
|
We may very well dip into files larger than 4G at some point, so 32-bit
values are not enough, and the 64-bit sized `off_t` doesn't fully make
sense either, as it features negative values.
Instead, switch to the explicit type of `u64` everywhere, which is the
same size on all platforms and is unsigned. The exception to this is
the threshold, which needs to be signed instead of unsigned.
|
|
|
|
The `--max-depth` option only controls until which depth individual file
sizes are printed, it does not stop the utility from traversing that
branch further (as the file sizes would be wrong otherwise).
Restructure the program to track the current depth, and return early if
the current depth is higher than the maximum allowed depth, which skips
all parts of the logic that are concerned with user output.
|
|
|
|
The apparent size is what `stat` says what we use. The non-apparent size
is the blocks that we actually use on-disk.
|
|
|
|
|
|
Replacement conditions for `requires_argument` have been chosen based
on what would be most convenient for implementing an eventual optional
argument mode.
|
|
Error::from_string_literal now takes direct char const*s, while
Error::from_string_view does what Error::from_string_literal used to do:
taking StringViews. This change will remove the need to insert `sv`
after error strings when returning string literal errors once
StringView(char const*) is removed.
No functional changes.
|
|
This commit moves the length calculations out to be directly on the
StringView users. This is an important step towards the goal of removing
StringView(char const*), as it moves the responsibility of calculating
the size of the string to the user of the StringView (which will prevent
naive uses causing OOB access).
|
|
These were accidental (or leftover) uses of String::characters() to
construct StringViews through its StringView(char const*) constructor.
Since this constructor is due to be removed, this will no longer work.
Plus this prevents strlen from being run on these strings unnecessarily.
|
|
|
|
du <filename> will not print anything until `-a` option was provided.
Fix the behaviour by taking into account the `-a` option only when a
directory is given as the input.
|
|
For each directory, we now go through each file and sum-up the contents.
|
|
This ports 'du' utility to LibMain. Also moves to use StringView and
StringView literals more instead of raw C strings.
|
|
|
|
AK's version should see better inlining behaviors, than the LibM one.
We avoid mixed usage for now though.
Also clean up some stale math includes and improper floatingpoint usage.
|
|
|
|
We already do this in most places, so the style should be consistent.
Also, Clang does not like it, as this could cause an unexpected compile
error if some statements are added to the default label or a new label
is added above it.
|
|
The LexicalPath instance methods dirname(), basename(), title() and
extension() will be changed to return StringView const& in a further
commit. Due to this, users creating temporary LexicalPath objects just
to call one of those getters will recieve a StringView const& pointing
to a possible freed buffer.
To avoid this, static methods for those APIs have been added, which will
return a String by value to avoid those problems. All cases where
temporary LexicalPath objects have been used as described above haven
been changed to use the static APIs.
|
|
Let's make it a bit more clear when we're appending the elements from
one vector to the end of another vector.
|
|
Add -h/--human-readable option to du.
|
|
|
|
|
|
Nobody seems to use this particular feature, in fact there were some
bugs which were uncovered by removing operator bool.
|
|
...and make it an enum class so people don't omit "OpenMode".
|
|
|
|
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 *
|
|
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED)
Since all of these checks are done in release builds as well,
let's rename them to VERIFY to prevent confusion, as everyone is
used to assertions being compiled out in release.
We can introduce a new ASSERT macro that is specifically for debug
checks, but I'm doing this wholesale conversion first since we've
accumulated thousands of these already, and it's not immediately
obvious which ones are suitable for ASSERT.
|
|
|