Add argument for recursive hashing #109
Labels
No labels
announcement
bug
build
CI
dependencies
documentation
duplicate
enhancement
experience feedback
feature request
github_actions
help wanted
install
invalid
Long-term
optimization
portability
question
target-specific
test issue
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-Cyan4973/xxHash#109
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Not a big deal on Unix, but kinda pita on Windows.
Current workaround:
(it's not that complicated, bit chatty)
Also see #87
dir /s /b **TARGET-DIR** | xxhsum --read-filenames-from-stdin > C:\my-resultopendir()-ish functionality. For example, https://github.com/cxong/tinydirxxhsum --show-hash-recursive **TARGET-DIR** > C:\my-resultopendir()other than shell, it may cause other problems. e.g Permission, race condition, networking, Unicode/MBCS path name, etc.for /R **TARGET-DIR** %f in (*) do ( xxhsum %f >> C:\my-result )cmd.exemust die :finnadie:Get-ChildItem **TARGET-DIR** -Recurse | where { !$_.PSIsContainer} | ForEach-Object {xxhsum $_.FullName} | Out-File C:\my-resultPersonally, I suppose "Plan C" may satisfy 70% of usage and I believe we should compromise with it.
But "Plan A" also would be nice since it's constructive and easy to implement without platform dependent functionality and/or external dependency.
Plan D (the best :-): add xxHash to RHash. See issue #26.
@data-man I'm really sorry but I can't read that issue 😢
But RHash looks good.
@t-mat
Sorry, machine translated:
Plan A looks interesting, it's also a fairly new feature, existing utilities like
md5sumdo not support it as far as I know.The "without platform dependent functionality" tag feels premature to me : we would need to be sure that
diroutput can be parsed safely, in a universal way, on all systems.Alternatively, it could be tagged as working on only a few tested systems, and gracefully refuse to work on others.
As stated in #87, another potential solution could be to support a "recursive mode", typically using
-rcommand, including all files in selected and included directories. It's also not supported bymd5sum, but it's a well-known capability of compression tools likegzip,xz,zstd,lz4etc., and we've got some code to make it work. The existing code is "reasonably portable" : it indeed depends on some OS-related libraries for directory discovery, but works well on a lot of OS, and is automatically disabled on unsupported OS.@t-mat
The
for /R **TARGET-DIR** %f in (*) do ( xxhsum %f >> C:\my-result )is fairly straightforward but awfully slow, thats why I am usingfor /D /r "%~f2" %%d in (*)in my snippet.A variant for WLS (using debian terminal on windows 10):
Assuming:
1.IFS=$'\n' makes the newline the only separator, so you can have whitespaces
Another method:
Select files to hash, copy all the routes using "shift+right click", paste into a txt like stdin.txt
remove leading and tailed quotations "" using "search and replace" on your favorite text editor.
save file as unix (LF) format. (windows format CR LF gives errors)
Run this command:
Now the hashes file contains just the files that you wanted to hash.
xxhsum 0.8.0 behaves oddly even without recursive traversal.
I asked to calculate hashes of files, so why it mentions dirs in the output and why the Cyrillic-named dir is suddenly not accessible?
It's caused by the shell which you're using. In this case,
xxhsumdoes nothing about wildcard. Usually, *nix flavor shell expands wildcard (globbing) such as*.*to filesystem entries including directory.For example, the following command shows actual expanded arguments.
I have no idea. On my terminal,
xxhsumfor directory which has Cyrillic name shows the following message as intended.But since error message suggests issue about permission, you can try some method to figure out what is happening
whoamicommand to make sure you're using your account or not.ls -ld Загрузки.@t-mat, I am a Windows 7 administrator with its shell and a few ported UNIX utils, nothing fancy.
Actually, 'denied' issue seems not to be related to permissions as follows