Browse Source

More docs. Add rmdir and unlink.

v0.7.4-release
Ryan 16 years ago
parent
commit
c326614c8d
  1. 34
      src/file.cc
  2. 24
      website/node.html

34
src/file.cc

@ -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);

24
website/node.html

@ -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>

Loading…
Cancel
Save