mirror of
https://github.com/neovim/neovim.git
synced 2024-12-29 14:41:06 -07:00
os/fs: Allow os_mkdir_recurse directory name to end with ///
This commit is contained in:
parent
030c608b7d
commit
fefcc01cc1
@ -366,11 +366,17 @@ int os_mkdir_recurse(const char *const dir, int32_t mode,
|
||||
}
|
||||
while (e != real_end) {
|
||||
if (e > past_head) {
|
||||
*e = '/';
|
||||
*e = PATHSEP;
|
||||
} else {
|
||||
*past_head = past_head_save;
|
||||
}
|
||||
e += strlen(e);
|
||||
const size_t component_len = strlen(e);
|
||||
e += component_len;
|
||||
if (e == real_end
|
||||
&& memcnt(e - component_len, PATHSEP, component_len) == component_len) {
|
||||
// Path ends with something like "////". Ignore this.
|
||||
break;
|
||||
}
|
||||
int ret;
|
||||
if ((ret = os_mkdir(curdir, mode)) != 0) {
|
||||
*failed_dir = curdir;
|
||||
|
@ -564,6 +564,28 @@ describe('fs function', function()
|
||||
eq(false, os_isdir('unit-test-directory/new-dir-recurse'))
|
||||
end)
|
||||
|
||||
it('succeeds to create a directory ending with ///', function()
|
||||
local mode = ffi.C.kS_IRUSR + ffi.C.kS_IWUSR + ffi.C.kS_IXUSR
|
||||
local ret, failed_str = os_mkdir_recurse(
|
||||
'unit-test-directory/new-dir-recurse///', mode)
|
||||
eq(0, ret)
|
||||
eq(nil, failed_str)
|
||||
eq(true, os_isdir('unit-test-directory/new-dir-recurse'))
|
||||
lfs.rmdir('unit-test-directory/new-dir-recurse')
|
||||
eq(false, os_isdir('unit-test-directory/new-dir-recurse'))
|
||||
end)
|
||||
|
||||
it('succeeds to create a directory ending with /', function()
|
||||
local mode = ffi.C.kS_IRUSR + ffi.C.kS_IWUSR + ffi.C.kS_IXUSR
|
||||
local ret, failed_str = os_mkdir_recurse(
|
||||
'unit-test-directory/new-dir-recurse/', mode)
|
||||
eq(0, ret)
|
||||
eq(nil, failed_str)
|
||||
eq(true, os_isdir('unit-test-directory/new-dir-recurse'))
|
||||
lfs.rmdir('unit-test-directory/new-dir-recurse')
|
||||
eq(false, os_isdir('unit-test-directory/new-dir-recurse'))
|
||||
end)
|
||||
|
||||
it('succeeds to create a directory tree', function()
|
||||
local mode = ffi.C.kS_IRUSR + ffi.C.kS_IWUSR + ffi.C.kS_IXUSR
|
||||
local ret, failed_str = os_mkdir_recurse(
|
||||
|
Loading…
Reference in New Issue
Block a user