summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYi, EungJun <semtlenori@gmail.com>2012-04-03 01:31:21 +0900
committerBen Noordhuis <info@bnoordhuis.nl>2012-05-01 15:19:37 +0200
commit4bd54dad33722e93bae5a16f6b274d08944c24cc (patch)
treeeba5bcacba54cf48cb29f817f393b523e3ff5b8d
parent6ba3e68bd2f9ad582ca0a20e1f42192ab527258e (diff)
downloadandroid-node-v8-4bd54dad33722e93bae5a16f6b274d08944c24cc.tar.gz
android-node-v8-4bd54dad33722e93bae5a16f6b274d08944c24cc.tar.bz2
android-node-v8-4bd54dad33722e93bae5a16f6b274d08944c24cc.zip
path: add path.sep to get the path separator.
-rw-r--r--doc/api/path.markdown16
-rw-r--r--lib/path.js2
-rw-r--r--test/simple/test-path.js8
3 files changed, 26 insertions, 0 deletions
diff --git a/doc/api/path.markdown b/doc/api/path.markdown
index 5e0957d257..d178b53f1f 100644
--- a/doc/api/path.markdown
+++ b/doc/api/path.markdown
@@ -138,3 +138,19 @@ an empty string. Examples:
path.extname('index')
// returns
''
+
+## path.sep
+
+The platform-specific file separator. `'\\'` or `'/'`.
+
+An example on linux:
+
+ 'foo/bar/baz'.split(path.sep)
+ // returns
+ ['foo', 'bar', 'baz']
+
+An example on windows:
+
+ 'foo\\bar\\baz'.split(path.sep)
+ // returns
+ ['foo', 'bar', 'baz']
diff --git a/lib/path.js b/lib/path.js
index 148b2af9a1..ad8fd8d787 100644
--- a/lib/path.js
+++ b/lib/path.js
@@ -258,6 +258,7 @@ if (isWindows) {
return outputParts.join('\\');
};
+ exports.sep = '\\';
} else /* posix */ {
@@ -373,6 +374,7 @@ if (isWindows) {
return outputParts.join('/');
};
+ exports.sep = '/';
}
diff --git a/test/simple/test-path.js b/test/simple/test-path.js
index caf86aa465..a5c7372d7d 100644
--- a/test/simple/test-path.js
+++ b/test/simple/test-path.js
@@ -273,3 +273,11 @@ relativeTests.forEach(function(test) {
});
assert.equal(failures.length, 0, failures.join(''));
+// path.sep tests
+if (isWindows) {
+ // windows
+ assert.equal(path.sep, '\\');
+} else {
+ // posix
+ assert.equal(path.sep, '/');
+}