summaryrefslogtreecommitdiff
path: root/Userland/Utilities/du.cpp
AgeCommit message (Collapse)Author
2022-12-12LibCore: Rename `Stream::read_all` to `read_until_eof`Tim Schumacher
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.
2022-12-06Everywhere: Rename to_{string => deprecated_string}() where applicableLinus Groh
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-06AK+Everywhere: Rename String to DeprecatedStringLinus Groh
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-11-19du: Port to Core::StreamSam Atkins
2022-07-24du: Consolidate all "do not print" conditionsTim Schumacher
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.
2022-07-24du: Only use unmodified file sizes internallyTim Schumacher
This keeps us from repeatedly applying the block size calculation on already processed values.
2022-07-24du: Use 64-bit integers when handling file sizes or related valuesTim Schumacher
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.
2022-07-24du: Fix a typo in the `--exclude-from` optionTim Schumacher
2022-07-24du: Don't stop descending even if the maximum depth is reachedTim Schumacher
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.
2022-07-21du: Implement the 1k block size short optionTim Schumacher
2022-07-21du: Invert apparent-size behaviourTim Schumacher
The apparent size is what `stat` says what we use. The non-apparent size is the blocks that we actually use on-disk.
2022-07-21du: Implement custom block sizesTim Schumacher
2022-07-21du: Replace home-grown block-based size calculation with `ceil_div`Tim Schumacher
2022-07-14LibCore: Replace the ArgsParser option argument setting with an enumTim Schumacher
Replacement conditions for `requires_argument` have been chosen based on what would be most convenient for implementing an eventual optional argument mode.
2022-07-12Everywhere: Split Error::from_string_literal and Error::from_string_viewsin-ack
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.
2022-07-12Everywhere: Explicitly specify the size in StringView constructorssin-ack
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).
2022-07-12Userland: Remove erroneous String -> char* -> StringView conversionssin-ack
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.
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-02-14Utilities: Fix du to print stats for regular filesPankaj Raghav
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.
2022-01-06du: Display true size of directory instead of 4 KiBLucas CHOLLET
For each directory, we now go through each file and sum-up the contents.
2022-01-01du: Port to LibMainKenneth Myhra
This ports 'du' utility to LibMain. Also moves to use StringView and StringView literals more instead of raw C strings.
2021-08-01Utilities: Remove unused header includesBrian Gianforcaro
2021-07-19Everywhere: Use AK/Math.h if applicableHendiadyoin1
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.
2021-07-13du: Don't fail immediately when directory can't be read (#8719)luk1337
2021-07-08Everywhere: Add break after the last case label before `default`Daniel Bertalan
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.
2021-06-30AK+Everywhere: Add and use static APIs for LexicalPathMax Wipfli
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.
2021-06-12AK: Rename Vector::append(Vector) => Vector::extend(Vector)Andreas Kling
Let's make it a bit more clear when we're appending the elements from one vector to the end of another vector.
2021-06-11Utilities/du: Add -h optionMarcus Nilsson
Add -h/--human-readable option to du.
2021-06-01Userland: Replace most printf-style APIs with AK::Format APIs :^)Linus Groh
2021-05-17Utilities: Correct non-standard assert macros includesJean-Baptiste Boric
2021-05-16AK+Userland: Remove nullability feature for the ByteBuffer typeGunnar Beutner
Nobody seems to use this particular feature, in fact there were some bugs which were uncovered by removing operator bool.
2021-05-12LibCore+Everywhere: Move OpenMode out of IODeviceAli Mohammad Pur
...and make it an enum class so people don't omit "OpenMode".
2021-05-03Userland: Fix 64-bit portability issuesGunnar Beutner
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
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-02-23Everywhere: Rename ASSERT => VERIFYAndreas Kling
(...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.
2021-01-12Userland: Move command-line utilities to Userland/Utilities/Andreas Kling