FileSystem::rename() fix renaming file/directory if only case changes#155
FileSystem::rename() fix renaming file/directory if only case changes#155dg merged 3 commits intonette:masterfrom
Conversation
When trying to rename file/directory itself in order to change only case of filename (eg. `test.php` to `Test.php`), the process fails as the method first [deletes](https://github.com/nette/utils/blob/master/src/Utils/FileSystem.php#L110) the desired file(name) prior to renaming it .. thus it deletes the original file/dir that was about to be renamed.
|
Good point. However, checking whether the files are the same should be done differently (I don't know how). For compatibility between NTFS and Linux. |
|
@dg you think |
|
Maybe compare |
|
I think the |
|
Realpath should do the work, I didn’t test it. It this case there shouldn’t be lower(). |
|
@dg updated |
|
Did you test it? I am not sure that realpath really works this way. |
|
@dg I did.. on OS preventing same filenames differing in case only, like Windows, realpath correctly transforms eg |
|
Great. But it seems that it breaks test… |
|
@dg should I remove the failing test altogether? As the failing |
|
Thanks, merged |
When trying to rename file/directory itself in order to change only case of filename (eg.
test.phptoTest.php), the process fails as the method first deletes the desired file(name) prior to renaming it .. thus it deletes the original file/dir that was about to be renamed.This change prevents that case.