-- die Funktion ermittelt rekursiv die ersten 'limit' Orte,
-- an denen die Datei 'filename' unterhalb des Pfades 'path' liegt,
-- und liefert als Ergebnis die vollständigen Pfade
-- in einem table zurück
local function search_file( path, filename, limit, result )
local result = result or {}
local limit = limit or math.huge
for file in SY_GetDirFiles( path ) do
if #result >= limit then break end
if file ~= "." and file ~= ".." then
local filepath = path .. "\\" .. file
local mode = SY_FileInfo( filepath, "mode" )
if mode == "directory" then
search_file( filepath, filename, limit, result )
elseif mode == "file" then
if file == filename then
result[#result+1] = filepath
end
else
error( "unknown mode - " .. tostring( mode ) )
end
end
end
return result
end
-- suchen nach der Datei aufform.rpt unterhalb vom Syslog-Verzeichnis
local path = os.getenv( "PRIMUSDIR" )
local files = search_file( path, "aufform.rpt" )
-- Pfade zu den gefundenen Dateien ausgeben
for nr, file in ipairs( files ) do
SY_Proto( nr .. ". Fundort: " .. file )
end