0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-29 15:06:33 +01:00

More docs. Add rmdir and unlink.

This commit is contained in:
Ryan 2009-05-26 12:11:31 +02:00
parent a9f29cd18d
commit c326614c8d
2 changed files with 49 additions and 9 deletions

View File

@ -84,6 +84,30 @@ static Handle<Value> Rename (const Arguments& args)
return Undefined();
}
DEFINE_SIMPLE_CB(Unlink)
static Handle<Value> Unlink (const Arguments& args)
{
if (args.Length() < 1 || !args[0]->IsString())
return ThrowException(BAD_ARGUMENTS);
HandleScope scope;
String::Utf8Value path(args[0]->ToString());
MAKE_CALLBACK_PTR
eio_unlink(*path, EIO_PRI_DEFAULT, AfterUnlink, callback);
return Undefined();
}
DEFINE_SIMPLE_CB(RMDir)
static Handle<Value> RMDir (const Arguments& args)
{
if (args.Length() < 1 || !args[0]->IsString())
return ThrowException(BAD_ARGUMENTS);
HandleScope scope;
String::Utf8Value path(args[0]->ToString());
MAKE_CALLBACK_PTR
eio_rmdir(*path, EIO_PRI_DEFAULT, AfterRMDir, callback);
return Undefined();
}
static int
AfterOpen (eio_req *req)
{
@ -355,13 +379,15 @@ File::Initialize (Handle<Object> target)
{
HandleScope scope;
// file system methods
NODE_SET_METHOD(target, "rename", Rename);
NODE_SET_METHOD(target, "stat", Stat);
// POSIX Wrappers
NODE_SET_METHOD(target, "close", Close);
NODE_SET_METHOD(target, "open", Open);
NODE_SET_METHOD(target, "write", Write);
NODE_SET_METHOD(target, "read", Read);
NODE_SET_METHOD(target, "rename", Rename);
NODE_SET_METHOD(target, "rmdir", RMDir);
NODE_SET_METHOD(target, "stat", Stat);
NODE_SET_METHOD(target, "unlink", Unlink);
NODE_SET_METHOD(target, "write", Write);
NODE_SET_METHOD(target, "strerror", StrError);

View File

@ -227,7 +227,7 @@ pool</a>
to execute file system calls.
<p>This part of the API is split into two parts: simple wrappers around
standard POSIX file I/O functions, and a user-friendly <code>File</code>
standard POSIX file I/O functions and a user-friendly <code>File</code>
object.
<h4 id="file_wrappers">POSIX Wrappers</h4>
@ -266,15 +266,29 @@ node.fs.rename("/tmp/hello", "/tmp/world", function (status) {
</pre>
<dl>
<dt><code>node.fs.rename(path1, path2, on_completion)</code></dt>
<dt><code>node.fs.rename(path1, path2, on_completion(status))</code></dt>
<dd>
<code>on_completion(status)</code>
<a
href="http://opengroup.org/onlinepubs/007908799/xsh/rename.html">rename(2)</a>
</dd>
<dt><code>node.fs.stat(path, on_completion)</code></dt>
<dt><code>node.fs.stat(path, on_completion(status, stats))</code></dt>
<dd>
<code>on_completion(status, stat_object)</code>
<a href="http://opengroup.org/onlinepubs/007908799/xsh/stat.html">stat(2)</a>
</dd>
<dt><code>node.fs.unlink(path, on_completion(status))</code></dt>
<dd>
<a
href="http://opengroup.org/onlinepubs/007908799/xsh/unlink.html">unlink(2)</a>
</dd>
<dt><code>node.fs.rmdir(path, on_completion(status))</code></dt>
<dd>
<a
href="http://opengroup.org/onlinepubs/007908799/xsh/rmdir.html">rmdir(2)</a>
</dd>
</dl>
<h4 id="file_file"><code>node.fs.File</code></h4>