-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add interface to core's File::Compare #255
Comments
Thanks for the suggestion. This does fit the mission of Path::Tiny -- making it easy to do things the "right way".
Path:Tiny can do a raw open on the two files and provide the handles to File::Compare. And it can default to a 64k buffer size, which appears recommended as a good default for I/O. I'm not inclined to support the Note to self: |
@ap -- you've got good perspective on APIs -- what do you think about naming? |
My first thought was “what’s wrong with I don’t feel that And I couldn’t immediately think of anything else that does. OTOH, taking a step back, I don’t actually disagree that Indeed, on second thought, it occurs to me that “compares” and “equal” both say the same thing, and that’s the problem, no? It’s just meh twice. You want to say what is equal. Which would be the contents, which means you are looking for something like My only misgiving with that particular suggestion is that it completely loses any connection to File::Compare as the underlying module. (FWIW I agree with not supporting |
It sounds like we're already assuming the return value will be reversed (unless we name it contents_differ). Looking through Path::Tiny's docs, there are a number of tests that are named The docs should also probably mention that File::Compare does not check if the underlying files are the same (it will happily take the same file as both inputs), so the user might still want to compare with realpath(). And there doesn't appear to be a portable way to check if a file is a hard-link of another: https://www.perlmonks.org/?node_id=859658 |
All the existing Just linguistically This all gets rather cumbersome IMO.
That’s a good point. I don’t know that I’m happy with that. |
Annoyingly,
|
The unix |
In the spirit of "write the docs first", here's what I propose. I think it's hard to misunderstand or misuse.
Note: there is a subtlety with |
LGTM |
I Just realized why i was having the opposite feeling. |
I often have to compare the contents pointed to by the paths. I had been using the digest method, which works fine for the purpose, but I just benchmarked against File::Compare and the latter is 15-30x faster, so I'm definitely switching to using compare.
According to
corelist
: File::Compare was first released with perl 5.004, so it would not add an additional dependency.The text was updated successfully, but these errors were encountered: