summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorTony Huang <cnwzhjs@gmail.com>2011-08-04 11:39:19 +0800
committerkoichik <koichik@improvement.jp>2011-08-06 15:02:25 +0900
commit891a6f24a0a6df5a23b4ca417cb701d6c6718b00 (patch)
tree4776a31bcb55ff99b309055133aa43330394be05 /doc
parent9e8d812ce998bf3ef2857c311730163b8fa45fef (diff)
downloadnodejs-891a6f24a0a6df5a23b4ca417cb701d6c6718b00.tar.gz
nodejs-891a6f24a0a6df5a23b4ca417cb701d6c6718b00.tar.bz2
nodejs-891a6f24a0a6df5a23b4ca417cb701d6c6718b00.zip
add the document of the new api routine: path.relative
Diffstat (limited to 'doc')
-rw-r--r--doc/api/path.markdown19
1 files changed, 19 insertions, 0 deletions
diff --git a/doc/api/path.markdown b/doc/api/path.markdown
index a074ed59b..2c34eaac4 100644
--- a/doc/api/path.markdown
+++ b/doc/api/path.markdown
@@ -71,6 +71,25 @@ Examples:
// if currently in /home/myself/node, it returns
'/home/myself/node/wwwroot/static_files/gif/image.gif'
+### path.relative(from, to)
+
+Solve the relative path from `from` to `to`.
+
+Sometimes we've got two absolute pathes, and we need to calculate the relative path from one to another.
+It's accually the reverse transform of path.resolve, which means we assume:
+
+ path.resolve(from, path.relative(from, to)) == path.resolve(to)
+
+Examples:
+
+ path.relative('C:\\orandea\\test\\aaa', 'C:\\orandea\\impl\\bbb')
+ // returns
+ '..\\..\\impl\\bbb'
+
+ path.relative('/data/orandea/test/aaa', '/data/orandea/impl/bbb')
+ // returns
+ '../../impl/bbb'
+
### path.dirname(p)
Return the directory name of a path. Similar to the Unix `dirname` command.