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)
{
{
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);
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>
</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>