Debian Codegraph @

docs/examples.html

raw
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4 <head>
5 <title>LuaFileSystem</title>
6 <link rel="stylesheet" href="doc.css" type="text/css"/>
7 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
8 </head>
9
10 <body>
11
12 <div id="container">
13
14 <div id="product">
15 <div id="product_logo">
16 <a href="http://lunarmodules.github.io/luafilesystem">
17 <img alt="LuaFileSystem" src="luafilesystem.png"/>
18 </a>
19 </div>
20 <div id="product_name"><big><strong>LuaFileSystem</strong></big></div>
21 <div id="product_description">File System Library for the Lua Programming Language</div>
22 </div> <!-- id="product" -->
23
24 <div id="main">
25
26 <div id="navigation">
27 <h1>LuaFileSystem</h1>
28 <ul>
29 <li><a href="index.html">Home</a>
30 <ul>
31 <li><a href="index.html#overview">Overview</a></li>
32 <li><a href="index.html#status">Status</a></li>
33 <li><a href="index.html#download">Download</a></li>
34 <li><a href="index.html#history">History</a></li>
35 <li><a href="index.html#credits">Credits</a></li>
36 </ul>
37 </li>
38 <li><a href="manual.html">Manual</a>
39 <ul>
40 <li><a href="manual.html#introduction">Introduction</a></li>
41 <li><a href="manual.html#building">Building</a></li>
42 <li><a href="manual.html#installation">Installation</a></li>
43 <li><a href="manual.html#reference">Reference</a></li>
44 </ul>
45 </li>
46 <li><strong>Examples</strong></li>
47 <li><a href="https://github.com/lunarmodules/luafilesystem">Project</a>
48 <ul>
49 <li><a href="https://github.com/lunarmodules/luafilesystem/issues">Bug Tracker</a></li>
50 <li><a href="https://github.com/lunarmodules/luafilesystem">Git</a></li>
51 </ul>
52 </li>
53 <li><a href="license.html">License</a></li>
54 </ul>
55 </div> <!-- id="navigation" -->
56
57 <div id="content">
58
59 <h2><a name="example"></a>Examples</h2>
60
61 <h3>Directory iterator</h3>
62
63 <p>The following example iterates over a directory and recursively lists the
64 attributes for each file inside it.</p>
65
66 <pre class="example">
67 local lfs = require"lfs"
68
69 function attrdir (path)
70 for file in lfs.dir(path) do
71 if file ~= "." and file ~= ".." then
72 local f = path..'/'..file
73 print ("\t "..f)
74 local attr = lfs.attributes (f)
75 assert (type(attr) == "table")
76 if attr.mode == "directory" then
77 attrdir (f)
78 else
79 for name, value in pairs(attr) do
80 print (name, value)
81 end
82 end
83 end
84 end
85 end
86
87 attrdir (".")
88 </pre>
89
90 </div> <!-- id="content" -->
91
92 </div> <!-- id="main" -->
93
94 <div id="about">
95 <p><a href="http://validator.w3.org/check?uri=referer">Valid XHTML 1.0!</a></p>
96 </div> <!-- id="about" -->
97
98 </div> <!-- id="container" -->
99
100 </body>
101 </html>