Difference between revisions of "Lua:getFileList"

From Cheat Engine
Jump to navigation Jump to search
(Created page with "getFileList(Path:string, searchMask:string OPTIONAL, SearchSubDirs: boolean OPTIONAL, DirAttrib: integer OPTIONAL): Returns an indexed table with filenames <pre> r = getFileLi...")
 
m
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
getFileList(Path:string, searchMask:string OPTIONAL, SearchSubDirs: boolean OPTIONAL, DirAttrib: integer OPTIONAL): Returns an indexed table with filenames
+
[[Category:Lua]]
 +
'''function''' getFileList(''Path'', [''SearchMask''], [''SearchSubDirs''], [''DirAttrib'']) ''':''' Table
 +
 
 +
Returns an indexed table containing the names of files in the specified path.
 +
 
 +
===Function Parameters===
 +
{|width="85%" cellpadding="10%" cellspacing="0" border="0"
 +
!align="left"|Parameter
 +
!align="left"|Type
 +
!style="width: 80%;background-color:white;" align="left"|Description
 +
|-
 +
|Path
 +
|String
 +
|The directory path to search.
 +
|-
 +
|SearchMask
 +
|String (optional)
 +
|A file mask (e.g., <code>"*.exe"</code>) to filter results. Default is <code>"*"</code>.
 +
|-
 +
|SearchSubDirs
 +
|Boolean (optional)
 +
|If true, searches subdirectories recursively. Default is false.
 +
|-
 +
|DirAttrib
 +
|Integer (optional)
 +
|Directory attribute filter. Default is 0.
 +
|}
 +
 
 +
===Returns===
 +
Table — An indexed table with the names of files found.
 +
 
 +
===Examples===
 
<pre>
 
<pre>
r = getFileList("C:\\CE\\autorun", "*.DLL", true)
+
local files = getFileList(getAutorunPath(), "*.txt")
require 'pl.pretty'.dump(r)
+
for i, name in ipairs(files) do
</pre>
+
  print(name)
Print result:
+
end
<pre>
+
 
{
+
-- Search recursively for all .dll files
  "C:\\CE\\autorun\\dlls\\MonoDataCollector32.dll",
+
local dlls = getFileList(getAutorunPath(), "*.dll", true)
  "C:\\CE\\autorun\\dlls\\MonoDataCollector64.dll",
+
for i, name in ipairs(dlls) do
  "C:\\CE\\autorun\\dlls\\32\\CEJVMTI.dll",
+
   print(name)
   "C:\\CE\\autorun\\dlls\\64\\CEJVMTI.dll"
+
end
}
 
 
</pre>
 
</pre>
 +
 +
== See also ==
 +
* [[Lua:getDirectoryList|getDirectoryList]]

Latest revision as of 19:16, 11 July 2025

function getFileList(Path, [SearchMask], [SearchSubDirs], [DirAttrib]) : Table

Returns an indexed table containing the names of files in the specified path.

Function Parameters[edit]

Parameter Type Description
Path String The directory path to search.
SearchMask String (optional) A file mask (e.g., "*.exe") to filter results. Default is "*".
SearchSubDirs Boolean (optional) If true, searches subdirectories recursively. Default is false.
DirAttrib Integer (optional) Directory attribute filter. Default is 0.

Returns[edit]

Table — An indexed table with the names of files found.

Examples[edit]

local files = getFileList(getAutorunPath(), "*.txt")
for i, name in ipairs(files) do
  print(name)
end

-- Search recursively for all .dll files
local dlls = getFileList(getAutorunPath(), "*.dll", true)
for i, name in ipairs(dlls) do
  print(name)
end

See also[edit]