From 3142ef46a3385b209f29d843cf20c8f02ad65905 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 27 Jan 2019 02:01:57 -0800 Subject: Added 'make directory' API --- files.moon | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'files.moon') diff --git a/files.moon b/files.moon index a9fbb5c..a86f60d 100644 --- a/files.moon +++ b/files.moon @@ -60,6 +60,9 @@ Files.list = (path)-> else run_cmd('find -L "'..path..'" -not -path "*/\\.*" -type f') or false return _BROWSE_CACHE[path] +Files.make_directory = (path)-> + run_cmd('mkdir '..path) + ok, lfs = pcall(require, "lfs") if ok raw_file_exists = (filename)-> @@ -92,12 +95,14 @@ if ok for i,f in ipairs(_BROWSE_CACHE[path]) if f\match("^%./") then _BROWSE_CACHE[path][i] = f\sub(3) return _BROWSE_CACHE[path] + + Files.make_directory = lfs.mkdir else unless run_cmd('find . -maxdepth 0') url = if jit 'https://github.com/spacewander/luafilesystem' else 'https://github.com/keplerproject/luafilesystem' - error "Could not find 'luafilesystem' module and couldn't run system command `find` (this might happen on Windows). Please install `luafilesystem` (which can be found at: #{url} or `luarocks install luafilesystem`)", 0 + error "Could not find 'luafilesystem' module and couldn't run system command `find` (this might happen on Windows). Please install `luafilesystem` (which can be found at: #{url} or `luarocks install luafilesystem`)\n#{lfs}\npackage.cpath: #{package.cpath}", 0 line_counter = re.compile([[ lines <- {| line (%nl line)* |} -- cgit v1.2.3