remove*() and empty*(): remove contents as Buffers to handle non-UTF-8 filenames on Linux #612
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.
This is the first part of fixing issue #575 that deals with non-UTF-8 filenames. I've modified
remove()
,removeSync()
,emptyDir()
andemptyDirSync()
to use{encoding: 'buffer'}
when callingfs.readdir*
, in order to more reliably remove contents that may not be convertible to UTF-8. This situation may only be possible on Linux file systems, but the changes and additional unit tests are working on Windows NTFS and Apple APFS.Further work is required to update
copy*()
(and thereforemove*()
) to close #575, but it was becoming a bit of a rabbit hole, so I wanted to get this part squared away first.Additionally, as a side effect of these changes, it is also possible to pass a
Buffer
input path toremove()
andremoveSync()
to remove a directory directly that may have an invalid UTF-8 name. This is not yet possible with theemptyDir*
functions because that first requires Buffer support inmkdirs
.Please advise if you would be willing to review + merge this PR, or if you would like to wait for the additional changes mentioned above.