path: add Buffer support in path methods #23722
Labels
buffer
Issues and PRs related to the buffer subsystem.
feature request
Issues that request new features to be added to Node.js.
path
Issues and PRs related to the path subsystem.
wontfix
Issues that will not be fixed.
Is your feature request related to a problem? Please describe.
PR #5616 gave us support for Buffer paths in all fs methods, primarily to allow interacting with files of unknown or invalid file encoding. One frustration has been that the path methods, which are often used in conjunction with fs methods, only accept strings. This makes it difficult to perform many higher-level fs operations in a Buffer-based (and therefore encoding agnostic) way, such as recursive move / copy / remove.
Describe the solution you'd like
Ideally, I would think that the path methods could be updated to also accept Buffer inputs, similarly to the fs methods, and to give Buffer output when requested. Looking at the current
path.js
code, this seems possible but by no means trivial. The current methods primarily iterate through the input strings character-by-character, looking for special values, so I think a similar method could be used for Buffers, or possibly in a string / Buffer agnostic way.Describe alternatives you've considered
Making these path methods Buffer-based could be well suited for a user-land module, especially since they are primarily utility methods and there's no interaction with the lower-level system.
The text was updated successfully, but these errors were encountered: