Repository navigation
du: implement it - #242
Open
metif12 wants to merge 1 commit into
Open
du: implement it#242metif12 wants to merge 1 commit into
metif12 wants to merge 1 commit into
Conversation
Recursive apparent-size summary with -a -b -B -c -d -h -H -k -m -s --max-depth --total --apparent-size and file operands. The walk and the size formatting live in common/du and src/du is a thin main, for the same reason df's logic does: v test only compiles _test.v files, so tests cannot see code sitting beside them. Human-readable sizes are reused from common/df rather than written a second time. Traversal is sorted so output is deterministic, and a missing path is reported as 'du: cannot access <p>: No such file or directory' with exit 1 while the remaining operands still run, which is what GNU does. Two documented divergences: the default reports apparent size in 1K blocks, which is GNU's --apparent-size accounting rather than its st_blocks allocation (V's Stat has no blocks field, and matching GNU here would need a hand-declared stat struct per platform), and --block-size takes plain decimal only.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
dufor recursive apparent-size summaries: one line per directory with its total, children printed before their parent, plus the usual modifiers.The walk and the formatting live in
common/du, withsrc/duan eleven-linemain, for the same reasondf's logic does:v test <dir>compiles only_test.vfiles, so a test beside the implementation cannot see it.Options:
-a -b -B -c -d -h -H -k -m -s --max-depth --total --apparent-sizeand file operands. Clusters like-sband-abare parsed directly, sincecommon.flag_parserdoes not expand them.du: cannot access <p>: No such file or directory, continues with the remaining operands, and exits 1, which is what GNU does.Measured against GNU 9.4 before writing the code, including
-d0,-d1,-a,-s,-c, multiple operands, and the--apparent-size -kform.Two notes on things I did not share:
human_readableis duplicated fromcommon/dfrather than imported. An earlier revision imported it, which stacked this PR on thedfone; a base branch in a fork cannot back a pull request here, so that draft could not be built at all. Keeping the two tools independent matters more than the ~25 lines, and the duplication is called out in a comment so it can be folded once both land.Two documented divergences. The default reports apparent size in 1K blocks, which is GNU's
--apparent-sizeaccounting rather than itsst_blocksallocation — V'sos.Statexposes noblocksfield, so matching GNU here needs a hand-declared stat struct per platform for a difference that only shows on small files. And--block-sizeaccepts plain decimal only.uutils 0.0.17's
duon Windows reports0for every block count, omits "cannot access" from its diagnostics, and exits 0 when a path is missing. None of those are copied; the tests pin GNU's behaviour instead.20 test functions, all green, including a control that confirmed they fail when the block rounding is broken.