Difference between revisions of "Lua:getDirectoryList"

From Cheat Engine
Jump to navigation Jump to search
m
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<pre>
+
[[Category:Lua]]
r = getDirectoryList("C:\\CE\\autorun", true)
+
'''function''' getDirectoryList(''Path'', [''SearchSubDirs'']) ''':''' Table
+
 
require 'pl.pretty'.dump(r)
+
Returns an indexed table containing the names of directories in the specified path.
</pre>
+
 
 +
===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.
 +
|-
 +
|SearchSubDirs
 +
|Boolean (optional)
 +
|If true, searches subdirectories recursively. Default is false.
 +
|}
  
Print result:
+
===Returns===
 +
Table — An indexed table with the names of directories found.
  
 +
===Examples===
 
<pre>
 
<pre>
{
+
local dirs = getDirectoryList(getAutorunPath())
  "C:\\CE\\autorun\\ce-plugins",
+
for i, name in ipairs(dirs) do
  "C:\\CE\\autorun\\ceshare",
+
   print(name)
   "C:\\CE\\autorun\\dlls",
+
end
  "C:\\CE\\autorun\\forms",
+
 
  "C:\\CE\\autorun\\images",
+
-- Search recursively
  "C:\\CE\\autorun\\xml",
+
local allDirs = getDirectoryList(getAutorunPath(), true)
  "C:\\CE\\autorun\\ce-plugins\\.git",
+
for i, name in ipairs(allDirs) do
  "C:\\CE\\autorun\\ce-plugins\\images",
+
   print(name)
  "C:\\CE\\autorun\\ceshare\\forms",
+
end
  "C:\\CE\\autorun\\ceshare\\images",
 
  "C:\\CE\\autorun\\dlls\\32",
 
  "C:\\CE\\autorun\\dlls\\64",
 
  "C:\\CE\\autorun\\dlls\\src",
 
  "C:\\CE\\autorun\\dlls\\src\\Common",
 
  "C:\\CE\\autorun\\dlls\\src\\Java",
 
  "C:\\CE\\autorun\\dlls\\src\\Mono",
 
  "C:\\CE\\autorun\\dlls\\src\\Java\\CEJVMTI",
 
  "C:\\CE\\autorun\\dlls\\src\\Java\\CEJVMTI\\CEJVMTI",
 
   "C:\\CE\\autorun\\dlls\\src\\Mono\\MonoDataCollector"
 
}
 
 
</pre>
 
</pre>
 +
 +
== See also ==
 +
* [[Lua:getFileList|getFileList]]

Latest revision as of 19:13, 11 July 2025

function getDirectoryList(Path, [SearchSubDirs]) : Table

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

Function Parameters[edit]

Parameter Type Description
Path String The directory path to search.
SearchSubDirs Boolean (optional) If true, searches subdirectories recursively. Default is false.

Returns[edit]

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

Examples[edit]

local dirs = getDirectoryList(getAutorunPath())
for i, name in ipairs(dirs) do
  print(name)
end

-- Search recursively
local allDirs = getDirectoryList(getAutorunPath(), true)
for i, name in ipairs(allDirs) do
  print(name)
end

See also[edit]