path.format(pathObject)
Returns a path string from an object. This is the opposite of path.parse
.
If pathObject
has dir
and base
properties, the returned string will be a concatenation of the dir
property, the platform-dependent path separator, and the base
property.
If the dir
property is not supplied, the root
property will be used as the dir
property. However, it will be assumed that the root
property already ends with the platform-dependent path separator. In this case, the returned string will be the concatenation fo the root
property and the base
property.
If both the dir
and the root
properties are not supplied, then the returned string will be the contents of the base
property.
If the base
property is not supplied, a concatenation of the name
property and the ext
property will be used as the base
property.
An example on Posix systems:
path.format({ root : "/", dir : "/home/user/dir", base : "file.txt", ext : ".txt", name : "file" }); // returns '/home/user/dir/file.txt'
An example on Windows:
path.format({ root : "C:\\", dir : "C:\\path\\dir", base : "file.txt", ext : ".txt", name : "file" }) // returns 'C:\\path\\dir\\file.txt'
Please login to continue.