From 9cbe5cba9047b449308e1365690b0a5acfdef181 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Fri, 24 Jun 2022 12:12:13 -0300 Subject: Move doc/us/ to docs/, replacing the gh-pages branch. --- docs/examples.html | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 docs/examples.html (limited to 'docs/examples.html') diff --git a/docs/examples.html b/docs/examples.html new file mode 100644 index 0000000..68756c8 --- /dev/null +++ b/docs/examples.html @@ -0,0 +1,101 @@ + + + + LuaFileSystem + + + + + + +
+ +
+ +
LuaFileSystem
+
File System Library for the Lua Programming Language
+
+ +
+ + + +
+ +

Examples

+ +

Directory iterator

+ +

The following example iterates over a directory and recursively lists the +attributes for each file inside it.

+ +
+local lfs = require"lfs"
+
+function attrdir (path)
+    for file in lfs.dir(path) do
+        if file ~= "." and file ~= ".." then
+            local f = path..'/'..file
+            print ("\t "..f)
+            local attr = lfs.attributes (f)
+            assert (type(attr) == "table")
+            if attr.mode == "directory" then
+                attrdir (f)
+            else
+                for name, value in pairs(attr) do
+                    print (name, value)
+                end
+            end
+        end
+    end
+end
+
+attrdir (".")
+
+ +
+ +
+ + + +
+ + + -- cgit v1.2.3-55-g6feb