joyent/node — pull request #8750 by chrisdickinson (2014-11-19 19:47:26+00:00)
Title: Add path.parse, path.format

Continuing from https://github.com/joyent/node/pull/7429.

The feature was originally given the [go-ahead](https://github.com/joyent/node/pull/2766#issuecomment-4036027) by @isaacs.
@roryrjb opened a [pr](https://github.com/joyent/node/pull/2766#issuecomment-4036027) that stalled -- I'm reopening this, having fixed the style issues.

Tested on Win7 + OSX 10.10.

/cc @tjfontaine @indutny

## path.parse

Returns an object from a path string.

An example on *nix:

path.parse('/home/user/dir/file.txt')
// returns
{
root : "/",
dir : "/home/user/dir",
base : "file.txt",
ext : ".txt",
name : "file"
}

An example on Windows:

path.parse('C:\\path\\dir\\index.html')
// returns
{
root : "C:\",
dir : "C:\path\dir",
base : "index.html",
ext : ".html",
name : "index"
}

## path.format

Returns a path string from an object, the opposite of `path.parse` above.

path.format({
root : "/",
dir : "/home/user/dir",
base : "file.txt",
ext : ".txt",
name : "file"
})
// returns
'/home/user/dir/file.txt'