diff --git a/ikc3/.ikc3_history b/ikc3/.ikc3_history
index c6577d0..3ab3c7a 100644
--- a/ikc3/.ikc3_history
+++ b/ikc3/.ikc3_history
@@ -1,4 +1,3 @@
-quote if true do if false do %KC3.Operator{sym: :-, symbol_value: 3} else fn (x) do x * x end end end
if true do if true do %KC3.Operator{sym: :-, symbol_value: 3} else fn (x) do x * x end end end
type(0)
type(-1)
@@ -97,3 +96,4 @@ a.tv_nsec
List.sort_by([1, 2, 3, 4], fn (a, b) { a > b })
List.sort_by([%{title: "Abc", time: %Time{}}, %{title: "Cde", time: %Time{tv_sec: 1000}}], fn (a, b) { a.time < b.time })
List.sort_by([%{title: "Abc", time: %Time{}}, %{title: "Cde", time: %Time{tv_sec: 1000}}], fn (a, b) { a.time > b.time })
+File.list_files_recursive("../www/pages")
diff --git a/lib/kc3/0.1/file.kc3 b/lib/kc3/0.1/file.kc3
index c6cc63a..89da485 100644
--- a/lib/kc3/0.1/file.kc3
+++ b/lib/kc3/0.1/file.kc3
@@ -19,6 +19,32 @@ defmodule File do
def list = cfn List "file_list" (Str, Result)
+ def list_files_recursive = fn {
+ (dir) { list_files_recursive(dir, "", []) }
+ ([], dir, acc) { List.sort(acc) }
+ ([file | rest], dir, acc) {
+ if (Str.starts_with?(file, ".") ||
+ Str.ends_with?(file, "~"))
+ list_files_recursive(rest, dir, acc) # skip
+ else
+ path = dir + file
+ if (File.is_directory?(path)) do
+ acc2 = list_files_recursive(File.list(path), path + "/", acc)
+ list_files_recursive(rest, dir, acc2)
+ else
+ list_files_recursive(rest, dir, [path | acc])
+ end
+ end
+ }
+ (path, dir, acc) {
+ if (File.is_directory?(path)) do
+ list_files_recursive(File.list(path), path + "/", acc)
+ else
+ list_files_recursive(rest, dir, [path | acc])
+ end
+ }
+ }
+
def name = cfn Str "file_name" (Str, Result)
def open_r = cfn S32 "file_open_r" (Str, Result)