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

fs: add Buffer support in fs methods #5616

Closed
wants to merge 3 commits into from

Commits on Mar 25, 2016

  1. Configuration menu
    Copy the full SHA
    dc12d84 View commit details
    Browse the repository at this point in the history
  2. fs: Buffer and encoding enhancements to fs API

    This makes several changes:
    
    1. Allow path/filename to be passed in as a Buffer on fs methods
    2. Add `options.encoding` to fs.readdir, fs.readdirSync, fs.readlink,
       fs.readlinkSync and fs.watch.
    3. Documentation updates
    
    For 1... it's now possible to do:
    
    ```js
    fs.open(Buffer('/fs/foo/bar'), 'w+', (err, fd) => { });
    ```
    
    For 2...
    ```js
    fs.readdir('/fs/foo/bar', {encoding:'hex'}, (err,list) => { });
    
    fs.readdir('/fs/foo/bar', {encoding:'buffer'}, (err, list) => { });
    ```
    
    encoding can also be passed as a string
    
    ```js
    fs.readdir('/fs/foo/bar', 'hex', (err,list) => { });
    ```
    
    The default encoding is set to UTF8 so this addresses the
    discrepency that existed previously between fs.readdir and
    fs.watch handling filenames differently.
    
    Fixes: nodejs#2088
    Refs: nodejs#3519
    Alternate: nodejs#3401
    jasnell committed Mar 25, 2016
    Configuration menu
    Copy the full SHA
    f4cfa60 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    9272f05 View commit details
    Browse the repository at this point in the history