summaryrefslogtreecommitdiffstatshomepage
path: root/plugins/util.lua
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2021-05-07 02:09:13 +1000
committer Vas Crabb <vas@vastheman.com>2021-05-07 02:14:05 +1000
commitfab84e8d2b9177e11d334a82892dc554d128052b (patch)
treeb7cbeb727891f6c09048f1f11f9dbe9576e348fe /plugins/util.lua
parent075d934ff422e6b03352d91877d4ec92fb218641 (diff)
Mostly revert "Create console history file in homepath (#8026)"
The change to make the console plugin work is preserved. This reverts commit 25137717c9392d142650fcd679b09c400a2f5c4a.
Diffstat (limited to 'plugins/util.lua')
-rw-r--r--plugins/util.lua55
1 files changed, 0 insertions, 55 deletions
diff --git a/plugins/util.lua b/plugins/util.lua
deleted file mode 100644
index 6b2d7f438bf..00000000000
--- a/plugins/util.lua
+++ /dev/null
@@ -1,55 +0,0 @@
-local lfs = require("lfs")
-
--- Returns true if dirname is an existing directory, false if not a directory,
--- or nil, an error message and a system dependent error code on error.
-local function is_dir(dirname)
- local ret, err, code = lfs.attributes(dirname, "mode")
- if ret == nil then
- return ret, err, code
- else
- return ret == "directory"
- end
-end
-
--- Get the directory name for the file.
-local function dirname(filename)
- if filename == "/" then
- return "/"
- end
- local parent = filename:match("(.*)/.")
- if parent then
- if parent == "" then
- parent = "/"
- end
- return parent
- end
- return "."
-end
-
--- Create dir and parents for dir if needed. Returns true on success,
--- nil, an error message and a system dependent error code on error.
-local function mkdir_recursive(dir)
- local ret, err, code = is_dir(dir)
- if ret == true then
- return true
- end
- local parent = dirname(dir)
- local ret, err, code = mkdir_recursive(parent)
- if not ret then
- return ret, err, code
- end
- return lfs.mkdir(dir)
-end
-
--- Create the parents of the file recursively if needed, returns true on success,
--- or nil, an error message and a system dependent error code on error.
-local function create_parent_dirs(filename)
- local parent = dirname(filename)
- return mkdir_recursive(parent)
-end
-
-return {
- dirname = dirname,
- mkdir_recursive = mkdir_recursive,
- create_parent_dirs = create_parent_dirs
-}