getFilesRecursive()
Adds filenames to the parameter 'files' from the given directory 'absolutePath' including all subdirectories.
Synopsis
void getFilesRecursive(dyn_string &files, const string absolutePath,
const string relativePath, string pattern = "*");
Parameters
Parameter | Meaning |
---|---|
files | List of files to add the new file names to. |
absolutePath | Directory to look for files. |
relativePath | Used to build the file list including the relative path. |
pattern |
File pattern used for searching file names, default is all ("*"). Pattern is case-sensitive also for Windows platform. Pattern is only applied to file names, not directory names. Example for search either *.pnl or *.xml: *.[px][nm][l] (would also find *.pml;*.xnl etc.) since "one" of the characters in square brackets is searched. For details, see patternMatch(). |
Return value
-
Description
Adds filenames to parameter 'files' from the given directory 'absolutePath' including all subdirectories.
Example
The following example creates a file list of the files in the directory "panels" and its sub directories and uses the relative path as path for the file list. The list is output after creating it.
-
main(mapping event) { dyn_string fils; dyn_string pat = "*.[px][nm][l]"; const string absPath = "D:/WinCC_OA_Projects/WinCCOA_Proj/panels"; const string relPath = "D:/WinCC_OA_Projects/WinCCOA_Proj/panels"; getFilesRecursive(fils, absPath, relPath, pat); DebugN("Files list:", fils); }
The file is output:
WCCOAui1:["Files:"][dyn_string 12 items
WCCOAui1: 1: "D:/WinCC_OA_Projects/WinCCOA_Proj/panels/filefunctions.pnl"
WCCOAui1: 2: "D:/WinCC_OA_Projects/WinCCOA_Proj/panels/filefunctions.pnl.bak"
WCCOAui1: 3: "D:/WinCC_OA_Projects/WinCCOA_Proj/panels/NeueDatei.pnl"
WCCOAui1: 4: "D:/WinCC_OA_Projects/WinCCOA_Proj/panels/NeueDatei.pnl.bak"
WCCOAui1: 5: "D:/WinCC_OA_Projects/WinCCOA_Proj/panels/newPanel.pnl"
WCCOAui1: 6: "D:/WinCC_OA_Projects/WinCCOA_Proj/panels/vision/DefaultPermission.pnl"
WCCOAui1: 7: "D:/WinCC_OA_Projects/WinCCOA_Proj/panels/vision/InternalDp.pnl"
WCCOAui1: 8: "D:/WinCC_OA_Projects/WinCCOA_Proj/panels/vision/Listing.pnl"
WCCOAui1:]
Assignment
File function
Availability
CTRL, UI