diff options
author | Mike Mason <ms13sp@gmail.com> | 2007-11-14 20:10:42 +0000 |
---|---|---|
committer | Mike Mason <ms13sp@gmail.com> | 2007-11-14 20:10:42 +0000 |
commit | 0d14e4cb5636a57c674a7076ab1605802cea85a2 (patch) | |
tree | 3b7974beb6b1c2001a8c9f0ea0b6c9dd6299ac17 /lib | |
parent | b4fcb1304664f42f344a724468a3fa6abee3ea4c (diff) | |
download | acf-core-0d14e4cb5636a57c674a7076ab1605802cea85a2.tar.bz2 acf-core-0d14e4cb5636a57c674a7076ab1605802cea85a2.tar.xz |
Changed to use posix instead of lfs
git-svn-id: svn://svn.alpinelinux.org/acf/core/trunk@302 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'lib')
-rw-r--r-- | lib/fs.lua | 18 | ||||
-rw-r--r-- | lib/service_model.lua | 2 |
2 files changed, 13 insertions, 7 deletions
@@ -2,21 +2,27 @@ module for generic filesystem funcs Copyright (c) Natanael Copa 2006 - + MM edited to use "posix" ]]-- module (..., package.seeall) -require ("lfs") +require ("posix") -- generic wrapper funcs function is_dir ( pathstr ) - return lfs.attributes ( pathstr, "mode" ) == "directory" + return posix.stat ( pathstr, "type" ) == "directory" end function is_file ( pathstr ) - return lfs.attributes ( pathstr, "mode" ) == "file" + return posix.stat ( pathstr, "type" ) == "regular" +end + +function is_link ( pathstr ) + return posix.stat ( pathstr, "type" ) == "link" end + + -- Returns the contents of a file as a string function read_file ( path ) @@ -64,10 +70,10 @@ end function find ( what, where ) -- returns an array of files under "where" that match what "f" local function find_files_as_array ( f, where, t ) - where = where or lfs.currentdir() + where = where or posix.getcwd() f = f or ".*" t = t or {} - for d in lfs.dir ( where ) do + for d in posix.files ( where ) do if fs.is_dir ( where .. "/" .. d ) and (d ~= ".") and ( d ~= "..") then find_files_as_array (f, where .. "/" .. d, t ) end diff --git a/lib/service_model.lua b/lib/service_model.lua index c619d61..3f81794 100644 --- a/lib/service_model.lua +++ b/lib/service_model.lua @@ -5,7 +5,7 @@ function create_service_model(cfglist, loglist, servlist, notepath) local me = {} local function get_any_pid(pname) - for e in lfs.dir("/proc") do + for e in posix.files("/proc") do if e == string.match(e, "^%d*$") then for line in io.lines("/proc/" .. e .. "/status") do tag, val = string.match(line, "^([^:]*):%s*(%S*)$"); |