diff --git a/README.md b/README.md index 2f51838..0fad4da 100644 --- a/README.md +++ b/README.md @@ -306,6 +306,7 @@ var fs = new Filer.FileSystem(); * [fs.mknod(path, mode, callback)](#mknod) * [fs.rmdir(path, callback)](#rmdir) * [fs.mkdir(path, [mode], callback)](#mkdir) +* [fs.mkdtemp(path, [mode], callback)](#mkdtemp) * [fs.readdir(path, callback)](#readdir) * [fs.close(fd, callback)](#close) * [fs.open(path, flags, [mode], callback)](#open) @@ -673,6 +674,30 @@ fs.mkdir('/home', function(err) { }); ``` +#### fs.mkdtemp(prefix, options, callback) + + +Makes a temporary directory with prefix supplied in `path` argument. Method will append the six randomly selected characters directly to the prefix. + +Asynchronous. Callback gets `(error, path)`, where path is a path to created directory. + +NOTE: Filer allows for, but ignores the optional `options` argument used in node.js. + +Example: + +```javascript +// Create tmp directory with prefix foo +fs.mkdtemp("foo-", function (error, path) { + //A new folder foo-xxxxxx will be created. Path contains a path to created folder. +}); + +fs.mkdtemp("/myDir/tmp", function (error, path) { + //Will create a new folder tmpxxxxxx inside myDir directory. + //Will throw error if myDir does not exist +}); + +``` + #### fs.readdir(path, callback) Reads the contents of a directory. Asynchronous [readdir(3)](http://pubs.opengroup.org/onlinepubs/009695399/functions/readdir.html).