aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2019-10-26 11:42:38 +0000
committers-ol <s-ol@users.noreply.github.com>2019-10-26 11:42:38 +0000
commita62f63bc00cd63a98b349a2574e3e9e14c95a441 (patch)
treebdf90208902ccd7558c177ec0308fbabcfb7df67
parentfix typo (diff)
downloadmmm-a62f63bc00cd63a98b349a2574e3e9e14c95a441.tar.gz
mmm-a62f63bc00cd63a98b349a2574e3e9e14c95a441.zip
implement children ordering in stores.fs
-rw-r--r--mmm/mmmfs/stores/fs.moon23
1 files changed, 18 insertions, 5 deletions
diff --git a/mmm/mmmfs/stores/fs.moon b/mmm/mmmfs/stores/fs.moon
index 1300d55..8aeaf65 100644
--- a/mmm/mmmfs/stores/fs.moon
+++ b/mmm/mmmfs/stores/fs.moon
@@ -22,18 +22,31 @@ class FSStore extends Store
-- fileders
list_fileders_in: (path='') =>
- paths = for entry_name in lfs.dir @root .. path
+ entries = {}
+ for entry_name in lfs.dir @root .. path
continue if '.' == entry_name\sub 1, 1
entry_path = @root .. "#{path}/#{entry_name}"
if 'directory' ~= lfs.attributes entry_path, 'mode'
continue
- "#{path}/#{entry_name}"
+ entries[entry_name] = "#{path}/#{entry_name}"
+
+ sorted = {}
+
+ order_file = @root .. "#{path}/$order"
+ if 'file' == lfs.attributes order_file, 'mode'
+ for line in io.lines order_file
+ path = assert entries[line], "entry in $order but not on disk: #{line}"
+ table.insert sorted, path
+ sorted[line] = true
+
+ entries = [path for entry, path in pairs entries when not sorted[entry]]
+ table.sort entries
+ for path in *entries
+ table.insert sorted, path
- table.sort paths
coroutine.wrap ->
- -- @TODO: respect $order
- for path in *paths
+ for path in *sorted
coroutine.yield path
create_fileder: (parent, name) =>