From c01aea7dfac5dc51c39db50c7650755fafcadbbe Mon Sep 17 00:00:00 2001 From: Grump Date: Thu, 23 Jul 2020 19:27:48 +0200 Subject: [PATCH] fix absolute path handling in createDirectory --- nativefs.lua | 2 +- test/main.lua | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/nativefs.lua b/nativefs.lua index d04068c..0712f05 100644 --- a/nativefs.lua +++ b/nativefs.lua @@ -318,7 +318,7 @@ function nativefs.getDriveList() end function nativefs.createDirectory(path) - local current = '' + local current = path:sub(1, 1) == '/' and '/' or '' for dir in path:gmatch('[^/\\]+') do current = current .. dir .. '/' local info = nativefs.getInfo(current, 'directory') diff --git a/test/main.lua b/test/main.lua index fae4948..9ccedaf 100644 --- a/test/main.lua +++ b/test/main.lua @@ -223,6 +223,7 @@ end function test_fs_createDirectory() notFailed(fs.createDirectory('data/a/b/c/defg/h')) + notEquals(fs.getInfo('data/a/b/c/defg/h'), nil) fs.remove('data/a/b/c/defg/h') fs.remove('data/a/b/c/defg') fs.remove('data/a/b/c') @@ -231,6 +232,7 @@ function test_fs_createDirectory() local d = fs.getWorkingDirectory() .. '/data/a' notFailed(fs.createDirectory(d)) + notEquals(fs.getInfo(d), nil) fs.remove(d) end