[tekui-devel] tekui: DirList:scanEntry() added

Timm S. Mueller tmueller at schulze-mueller.de
Thu Sep 11 17:23:31 CEST 2008


details:   http://hg.teklib.org/tekui/rev/ef686a0f90b6
changeset: 17:ef686a0f90b6
user:      Timm S. Mueller <tmueller at schulze-mueller.de>
date:      Wed Sep 10 17:24:59 2008 +0200
description:
DirList:scanEntry() added

diffs (truncated from 111 to 100 lines):

diff -r e14e91fabc50 -r ef686a0f90b6 doc/manual.html
--- a/doc/manual.html	Wed Sep 10 14:53:13 2008 +0200
+++ b/doc/manual.html	Wed Sep 10 17:24:59 2008 +0200
@@ -419,7 +419,7 @@
 			</p>
 			<hr />
 		</div>
-		<div class="node"><h2><a name="tek.ui.class.dirlist" id="tek.ui.class.dirlist">DirList (v5.2)</a></h2>
+		<div class="node"><h2><a name="tek.ui.class.dirlist" id="tek.ui.class.dirlist">DirList (v6.0)</a></h2>
 			<div class="definition"><dfn>LINEAGE</dfn>
 				<blockquote>
 					<p>
@@ -596,6 +596,17 @@
 				This function aborts the coroutine which is
 				currently scanning the directory. The caller of this function must
 				be running in its own coroutine.
+			</p>
+			<hr />
+		</div>
+		<div class="node"><h3><a name="DirList:scanEntry" id="DirList:scanEntry"><code>table, type = DirList:scanEntry(path, name, idx)</code></a></h3>
+			<p>
+				Scans a single entry
+				<code>name</code> in a directory named <code>path</code>. <code>idx</code> is the entry number
+				with which this scanned entry will appear in the directory listing.
+				<code>table</code> is an array of strings, containing entries like name, size,
+				date, permissions, modification date etc. The <code>type</code> return value
+				corresponds to the return values of <a href="#DirList:getFileStat"><code>DirList:getFileStat()</code></a>.
 			</p>
 			<hr />
 		</div>
@@ -7095,7 +7106,7 @@ Class.checkDescend(Button, Area)
 </pre>
 		<hr />
 		<p>
-			Document generated on Wed Sep 10 14:30:33 2008
+			Document generated on Wed Sep 10 17:20:47 2008
 		</p>
 	</div>
 	</body>
diff -r e14e91fabc50 -r ef686a0f90b6 tek/ui/class/dirlist.lua
--- a/tek/ui/class/dirlist.lua	Wed Sep 10 14:53:13 2008 +0200
+++ b/tek/ui/class/dirlist.lua	Wed Sep 10 17:24:59 2008 +0200
@@ -71,7 +71,7 @@ local stat = lfs.attributes
 local stat = lfs.attributes
 
 module("tek.ui.class.dirlist", tek.ui.class.group)
-_VERSION = "DirList 5.3"
+_VERSION = "DirList 6.0"
 
 local DirList = _M
 
@@ -364,6 +364,30 @@ function DirList:abortScan()
 	end
 end
 
+-------------------------------------------------------------------------------
+--	table, type = DirList:scanEntry(path, name, idx): Scans a single entry
+--	{{name}} in a directory named {{path}}. {{idx}} is the entry number
+--	with which this scanned entry will appear in the directory listing.
+--	{{table}} is an array of strings, containing entries like name, size,
+--	date, permissions, modification date etc. The {{type}} return value
+--	corresponds to the return values of DirList:getFileStat().
+-------------------------------------------------------------------------------
+
+function DirList:scanEntry(path, name, idx)
+	local mode = self:getFileStat(path, name, "mode", idx)
+	return
+	{
+		name,
+		mode == "directory" and self.Locale.DIR or
+			self:getFileStat(path, name, "size", idx)
+	},
+	mode
+end
+
+-------------------------------------------------------------------------------
+--	DirList:scanDir(path)
+-------------------------------------------------------------------------------
+
 function DirList:scanDir(path)
 	local app = self.Application
 
@@ -396,26 +420,14 @@ function DirList:scanDir(path)
 					end
 				end
 				n = n + 1
-
-				local fullname = path .. "/" .. name
-				local isdir =
-					self:getFileStat(path, name, "mode", n) == "directory"
-				insert(list,
-				{
-					{
-						name,
-						isdir and self.Locale.DIR or
-							self:getFileStat(path, name, "size", n),
-					},
-					isdir
-				})
+				insert(list, { self:scanEntry(path, name, n) })


More information about the tekui-devel mailing list