Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.



Introduced in

Version:1.18

Description

Description:

Returns an array with all matching files and folders found in the specified directory. Does not search sub-folders.

The element syntax and data differ between unpacked and exported (packed) missions:

Code Block
titleUnpacked Mission
linenumberstrue
listfiles ["","subfolder\*.paa",false,false]; // empty array <-- does not support folders in the file filter
listfiles ["subfolder","*.paa",false,false]; // filtered array of files: [["file","subfolderpath"],...] <-- split output requires path combination when the file needs to be called


Code Block
titlePacked Mission
linenumberstrue
listfiles ["","subfolder\*.paa",false,false]; // subfolder filter (1) included, [["subfolder\file",""],...] <-- path inclusion clutters file lists, but streamlines calling the files
listfiles ["subfolder","*.paa",false,false]; // subfolder filter (0) ignored, [["subfolder\file",""],...] <-- filter that works with unpacked missions does not work with packed missions


Syntax

Syntax:listFiles [dir, fileMask, profileDir, absoluteDir]
Parameters:
  • dir: String - Sub-folder to search in.

  • fileMask: String - Mask of filename to search for. Wildcards are supported (uses "*" and "?").
  • profileDir: Boolean - If true, dir is searched relatively to the user profile folder. If false, dir is relative to the mission directory.
  • absoluteDir: Boolean - If true, dir can be an absolute path (in which case, profileDir is ignored).
Return Value:Array - Array of files / folders in the searched folder. The format of each array element is: ["filename", "dir\filename"]. If nothing is found, an empty array is returned.

Examples

Examples:
Lists all mission folders in the user profile directory:
listFiles ["mpmissions", "*.*", true]
Lists all files in the mission folder:
listFiles ["", "*.*", false]
Lists all files at the root level of C:\:
listFiles ["C:\", "*.*", false, true]

Additional Information

See also: getDirectory
Multiplayer:
Problems:

Notes