aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-04-01 09:36:43 -0700
committerAlon Zakai <alonzakai@gmail.com>2014-04-01 09:38:12 -0700
commit04903aab84d94db3f5c0534e9eae0a6cdc6816ba (patch)
tree7c558483e5962e2c5a0bad10c7af50e27c9e23ef
parent927f26f3729fc5279e0cb4481fb0c484ec6255c0 (diff)
fix mkdir on a path ending in a slash; fixes #2263 and #2258
-rw-r--r--src/library.js3
-rw-r--r--tests/test_core.py4
2 files changed, 7 insertions, 0 deletions
diff --git a/src/library.js b/src/library.js
index 881fa54b..e0d8c5b7 100644
--- a/src/library.js
+++ b/src/library.js
@@ -325,6 +325,9 @@ LibraryManager.library = {
// int mkdir(const char *path, mode_t mode);
// http://pubs.opengroup.org/onlinepubs/7908799/xsh/mkdir.html
path = Pointer_stringify(path);
+ // remove a trailing slash, if one - /a/b/ has basename of '', but
+ // we want to create b in the context of this function
+ if (path[path.length-1] === '/') path = path.substr(0, path.length-1);
try {
FS.mkdir(path, mode, 0);
return 0;
diff --git a/tests/test_core.py b/tests/test_core.py
index 33e0b99f..a1fcc3da 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -4095,6 +4095,10 @@ def process(filename):
src = open(path_from_root('tests', 'dirent', 'test_readdir.c'), 'r').read()
self.do_run(src, 'success', force_c=True)
+ def test_readdir_empty(self):
+ src = open(path_from_root('tests', 'dirent', 'test_readdir_empty.c'), 'r').read()
+ self.do_run(src, 'success', force_c=True)
+
def test_stat(self):
src = open(path_from_root('tests', 'stat', 'test_stat.c'), 'r').read()
self.do_run(src, 'success', force_c=True)