From a96cb599a24a578a98af2e70da40037c00a7db6b Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Fri, 23 Jan 2009 14:35:39 +0000 Subject: 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 --- lib/fs.lua | 27 ++++++++------------------- 1 file 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 -- cgit v1.2.3