getFileNames()

Lists the files or sub directories of a directory.

Synopsis

dyn_string getFileNames([string dir = "." [, string pattern = "*" [, int filter = FILTER_FILES] ]);

Parameters

Parameter Description
dir

Directory, for example, ".", "..", "/usr", PROJ_PATH, "C://"

If the first argument is a path of a file or a path of a nonexistent file/directory, an empty string is returned.

pattern Pattern, for example, "*", "*.bak" oder "?oo?.i*". Pattern is case-sensitive also for Windows platform.
filter Filter can be a either FILTER_FILES (files) or FILTER_DIRS (directories) or a bit-wise OR combination of FILTER_FILES and FILTER_DIRS.

Return value

List with file or directory names

Description

Returns a list of all file or directory names in the specified directory dir that match a pattern pattern.

Example

In the following example, all the files in the TEMP directory whose name ends in tmp will be displayed:

main()
{
  int i;
  dyn_string s = getFileNames("C:/TEMP", "*.tmp");

// Alle TMP-Dateien anzeigen
  for(i=1; i<=dynlen(s); i++)
  {
    DebugN(i, "", s[i]);
  }
}

Returns all sub directories in the directory D:/Projects:

main()
{
  int i;
  dyn_string s = getFileNames("D:/Projekte", "*", FILTER_DIRS);
  for(i=1; i<=dynlen(s); i++)
  {
    DebugN(i, "", s[i]);
  }
}

Assignment

File function

Availability

CTRL