lzwfs wip
This commit is contained in:
@@ -157,9 +157,11 @@ local function split(str, pattern)
|
||||
end
|
||||
|
||||
local function matchesFilter(fname)
|
||||
for _, filter in pairs(filters) do
|
||||
if fname:match(filter) then
|
||||
return true
|
||||
if not fname:find('lzwfs') then -- don't compress anything with lzwfs in name (sigh)
|
||||
for _, filter in pairs(filters) do
|
||||
if fname:match(filter) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -193,7 +195,7 @@ function fs.open(fname, flags)
|
||||
end,
|
||||
}
|
||||
elseif flags == 'w' or flags == 'a' then
|
||||
if not matchesFilter(fs.combine(fname, '')) or true then
|
||||
if not matchesFilter(fs.combine(fname, '')) then
|
||||
return native.open(fname, flags)
|
||||
end
|
||||
|
||||
|
||||
@@ -15,4 +15,4 @@ end
|
||||
|
||||
os.run(_ENV, '/packages/lzwfs/lzwfs.lua')
|
||||
fs.option('compression', 'filters', config.filters)
|
||||
fs.option('compression', 'enable', config.enabled)
|
||||
fs.option('compression', 'enabled', config.enabled)
|
||||
|
||||
@@ -7,9 +7,9 @@ local fs = _G.fs
|
||||
local config = Config.load('lzwfs', {
|
||||
enabled = false,
|
||||
filters = {
|
||||
'/packages',
|
||||
'/sys',
|
||||
'/usr/config',
|
||||
'packages/',
|
||||
'sys/',
|
||||
'usr/config/',
|
||||
}
|
||||
})
|
||||
|
||||
@@ -70,8 +70,10 @@ local function rewriteFiles(p)
|
||||
local function recurse(path)
|
||||
_G._syslog('rewriting: ' .. path)
|
||||
if fs.isDir(path) then
|
||||
for _, v in pairs(fs.list(path)) do
|
||||
recurse(fs.combine(path, v))
|
||||
for _, v in pairs(fs.listEx(path)) do
|
||||
if not v.isReadOnly then
|
||||
recurse(fs.combine(path, v.name))
|
||||
end
|
||||
end
|
||||
else
|
||||
local c = Util.readFile(path)
|
||||
@@ -116,7 +118,7 @@ function tab:eventHandler(event)
|
||||
if self.checkbox.value ~= config.enabled then
|
||||
if not self.checkbox.value then
|
||||
fs.option('compression', 'filters', { })
|
||||
self:rewriteFiles(config.filters)
|
||||
rewriteFiles(config.filters)
|
||||
fs.option('compression', 'enabled', false)
|
||||
else
|
||||
fs.option('compression', 'enabled', true)
|
||||
|
||||
Reference in New Issue
Block a user