summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2009-01-23 14:35:39 +0000
committerTed Trask <ttrask01@yahoo.com>2009-01-23 14:35:39 +0000
commita96cb599a24a578a98af2e70da40037c00a7db6b (patch)
treea6dd397671c1e73d34d2ac83051e6ce85c6971cc
parentca4e70fd0fb8a22e47aec4418ce2e76ffdf1fadb (diff)
downloadacf-core-a96cb599a24a578a98af2e70da40037c00a7db6b.tar.bz2
acf-core-a96cb599a24a578a98af2e70da40037c00a7db6b.tar.xz
Modifed fs.lua to remove unnecessary calls to io.popen.
git-svn-id: svn://svn.alpinelinux.org/acf/core/trunk@1694 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r--lib/fs.lua27
1 files changed, 8 insertions, 19 deletions
diff --git a/lib/fs.lua b/lib/fs.lua
index 954ac0d..f484bf1 100644
--- a/lib/fs.lua
+++ b/lib/fs.lua
@@ -44,22 +44,21 @@ end
-- Creates a directory if it doesn't exist, including the parent dirs
function create_directory ( path )
- local p, i
- p = ""
- for i in string.gmatch(path, "/*[^/]+") do
- p = p .. i
- posix.mkdir(p)
+ local pos = string.find(path, "/")
+ while pos do
+ posix.mkdir(string.sub(path, 1, pos))
+ pos = string.find(path, "/", pos+1)
end
+ posix.mkdir(path)
return is_dir(path)
end
--- Creates a blank file
+-- Creates a blank file (and the directory if necessary)
function create_file ( path )
path = path or ""
if dirname(path) and not posix.stat(dirname(path)) then create_directory(dirname(path)) end
- local cmd = "touch "..format.escapespecialcharacters(path)
- local f = io.popen(cmd)
- f:close()
+ local f = io.open(path, "w")
+ if f then f:close() end
return is_file(path)
end
@@ -117,16 +116,6 @@ function write_line_file ( path, str )
end
end
-
---will return a string with md5sum and filename
-function md5sum_file ( path )
- local cmd = "/usr/bin/md5sum "..format.escapespecialcharacters(path)
- f = io.popen(cmd)
- local checksum = f:read("*a")
- f:close()
- return checksum
-end
-
-- iterator function for finding dir entries matching filespec (what)
-- starting at where, or currentdir if not specified.
-- Finds regexes, not fileglobs