diff --git a/src/lua/fio.c b/src/lua/fio.c index 32b26e7fa0927a02462b256e7fb60b661ad79b35..90281805960ec70bb6c4ffde65489fb790586ac7 100644 --- a/src/lua/fio.c +++ b/src/lua/fio.c @@ -486,7 +486,7 @@ lbox_fio_mkdir(struct lua_State *L) if (top >= 2) mode = lua_tointeger(L, 2); else - mode = 0; + mode = 0777; lua_pushboolean(L, coeio_mkdir(pathname, mode) == 0); return 1; } diff --git a/test/app/fio.result b/test/app/fio.result index 1f8f7c5367502d5ae7ad0963643b104b6b160fe8..ef3469c2f33869b7f1c672c23949be92350bb434 100644 --- a/test/app/fio.result +++ b/test/app/fio.result @@ -309,14 +309,32 @@ bit.band(fio.stat(file4).mode, 0x1FF) == 0x1F8 --- - true ... +dir1 = fio.pathjoin(tmpdir, 'dir1') +--- +... +dir2 = fio.pathjoin(tmpdir, 'dir2') +--- +... fio.mkdir(nil) --- - error: Usage fio.mkdir(pathname[, mode]) ... -fio.mkdir(fio.pathjoin(tmpdir, "dir")) +fio.mkdir(dir1) -- standard mode +--- +- true +... +fio.mkdir(dir2, 1) -- custom mode --- - true ... +string.format('%04o', bit.band(fio.stat(dir1).mode, 0x1FF)) +--- +- '0777' +... +string.format('%04o', bit.band(fio.stat(dir2).mode, 0x1FF)) +--- +- '0001' +... -- cleanup directories { fh1:close(), fh3:close() } --- @@ -334,7 +352,11 @@ fio.rmdir(nil) --- - error: 'Usage: fio.rmdir(pathname)' ... -fio.rmdir(fio.pathjoin(tmpdir, "dir")) +fio.rmdir(dir1) +--- +- true +... +fio.rmdir(dir2) --- - true ... diff --git a/test/app/fio.test.lua b/test/app/fio.test.lua index 7cd7d64c0db13ed0f594ee6fdb4028d166c40100..242b6c274943158769ba5cf4a00afd6d150c482e 100644 --- a/test/app/fio.test.lua +++ b/test/app/fio.test.lua @@ -103,15 +103,21 @@ bit.band(fh3:stat().mode, 0x1FF) == 0x1F8 bit.band(fio.stat(file4).mode, 0x1FF) == 0x1F8 +dir1 = fio.pathjoin(tmpdir, 'dir1') +dir2 = fio.pathjoin(tmpdir, 'dir2') fio.mkdir(nil) -fio.mkdir(fio.pathjoin(tmpdir, "dir")) +fio.mkdir(dir1) -- standard mode +fio.mkdir(dir2, 1) -- custom mode +string.format('%04o', bit.band(fio.stat(dir1).mode, 0x1FF)) +string.format('%04o', bit.band(fio.stat(dir2).mode, 0x1FF)) -- cleanup directories { fh1:close(), fh3:close() } { fh1:close(), errno.strerror(), fh3:close(), errno.strerror() } fio.rmdir(nil) -fio.rmdir(fio.pathjoin(tmpdir, "dir")) +fio.rmdir(dir1) +fio.rmdir(dir2) { fio.unlink(file1), fio.unlink(file2), fio.unlink(file3), fio.unlink(file4) } { fio.unlink(file1), fio.unlink(file2), fio.unlink(file3), fio.unlink(file4) }