diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2018-11-20 14:52:59 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2018-11-20 14:54:40 -0800 |
| commit | 2bbc035f5dcc3ecd62724b9d1de0e7e3ea902379 (patch) | |
| tree | 34a83497f7570946b6252183b3e8fe0ce2010595 /files.lua | |
| parent | f30413853063483147d941ffccc4b663b71bc943 (diff) | |
Simplifying the filesystem code (no longer entangled with nomsupath) and
using that to simplify the tools. Now the tools directly take lists of
file paths rather than things that might go through nomsupath or
directories or get processed by filetype. Use your shell for globbing stuff like
`nomsu tools/test.nom core/*.nom`
Diffstat (limited to 'files.lua')
| -rw-r--r-- | files.lua | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -37,12 +37,13 @@ Files.read = function(filename) do local file_contents = _FILE_CACHE[filename] if file_contents then - return file_contents + return file_contents or nil end end - if filename == 'stdin' then + if filename == 'stdin' or filename == '-' then local contents = io.read('*a') Files.spoof('stdin', contents) + Files.spoof('-', contents) return contents end local file = io.open(filename) @@ -52,7 +53,7 @@ Files.read = function(filename) local contents = file:read("*a") file:close() _FILE_CACHE[filename] = contents - return contents + return contents or nil end local match, gsub do @@ -71,7 +72,7 @@ Files.exists = function(path) if _SPOOFED_FILES[path] then return true end - if path == 'stdin' then + if path == 'stdin' or path == '-' then return true end if run_cmd("ls " .. tostring(sanitize(path))) then @@ -82,7 +83,7 @@ end Files.list = function(path) if not (_BROWSE_CACHE[path]) then local files - if _SPOOFED_FILES[path] or path == 'stdin' then + if _SPOOFED_FILES[path] or path == 'stdin' or path == '-' then _BROWSE_CACHE[path] = { path } @@ -107,14 +108,14 @@ if ok then if _SPOOFED_FILES[path] then return true end - if path == 'stdin' or raw_file_exists(path) then + if path == 'stdin' or path == '-' or raw_file_exists(path) then return true end return false end Files.list = function(path) if not (_BROWSE_CACHE[path]) then - if _SPOOFED_FILES[path] or path == 'stdin' then + if _SPOOFED_FILES[path] or path == 'stdin' or path == '-' then _BROWSE_CACHE[path] = { path } |
