Skip to content
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

Additional File functions #4712

Merged
merged 2 commits into from
May 21, 2021
Merged

Additional File functions #4712

merged 2 commits into from
May 21, 2021

Conversation

MGatner
Copy link
Member

@MGatner MGatner commented May 20, 2021

Description
Adds a couple more functions to the filesystem_helper: directoy_mirror() (from @paulbalandan's ComposerScripts PR) as samefile()`.

Checklist:

  • Securely signed commits
  • Component(s) with PHPdocs
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

system/Helpers/filesystem_helper.php Outdated Show resolved Hide resolved
system/Helpers/filesystem_helper.php Outdated Show resolved Hide resolved
*/
function same_file(string $file1, string $file2): bool
{
return is_file($file1) && is_file($file2) && md5_file($file1) === md5_file($file2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use hash_equals

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems like an unnecessary measure since there are no cryptography concerns here and we already know the string lengths will match. How does this improve on ===?

@MGatner MGatner requested a review from paulbalandan May 21, 2021 14:28
@MGatner MGatner merged commit 6da0e5b into codeigniter4:develop May 21, 2021
@MGatner MGatner deleted the file-helper branch May 21, 2021 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants