diff options
author | Marius <mariausol@gmail.com> | 2012-05-24 21:20:13 +0300 |
---|---|---|
committer | Marius <mariausol@gmail.com> | 2012-05-24 21:20:13 +0300 |
commit | 7f26897aecc7d4bc71486a4cb658cb6b4843aa5d (patch) | |
tree | 75e2cf8d2c8a2078fc71341bb6032697227078ce /scripts | |
parent | e6e3ff321b035d7d3ed512871d0cbd802c4b7368 (diff) | |
download | context-7f26897aecc7d4bc71486a4cb658cb6b4843aa5d.tar.gz |
beta 2012.05.24 19:36
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/context/lua/mtx-watch.lua | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/scripts/context/lua/mtx-watch.lua b/scripts/context/lua/mtx-watch.lua index 118d1a815..36a3176c4 100644 --- a/scripts/context/lua/mtx-watch.lua +++ b/scripts/context/lua/mtx-watch.lua @@ -70,7 +70,6 @@ local function noset(t) end end - -- todo: split order (o-name.luj) and combine with atime to determine sort order. local function glob(files,path) -- some day: sort by name (order prefix) and atime @@ -89,8 +88,10 @@ local function glob(files,path) -- some day: sort by name (order prefix) and ati glob(files,name) end elseif name:find(".%luj$") then - -- files[name] = a.change or a.ctime or a.modification or a.mtime - files[#files+1] = { dirname(name), basename(name) } + local bname = basename(name) + local dname = dirname(name) + local order = tonumber(bname:match("^(%d+)")) or 0 + files[#files+1] = { dname, bname, order } end end end @@ -98,13 +99,31 @@ end local clock = os.gettimeofday or os.time -- we cannot trust os.clock on linux +-- local function filenamesort(a,b) +-- local fa, da = a[1], a[2] +-- local fb, db = b[1], b[2] +-- if da == db then +-- return fa < fb +-- else +-- return da < db +-- end +-- end + local function filenamesort(a,b) - local fa, da = a[1], a[2] - local fb, db = b[1], b[2] - if da == db then - return fa < fb + local fa, oa = a[2], a[3] + local fb, ob = b[2], b[3] + if fa == fb then + if oa == ob then + return a[1] < b[1] -- order file dir + else + return oa < ob -- order file + end else - return da < db + if oa == ob then + return fa < fb -- order file + else + return oa < ob -- order file + end end end |