aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)