requestFileList()

The function requestFileList() requests a file list from the manager with the specified manager Id.

Synopsis

dyn_mapping requestFileList(int manId, string|dyn_string dirs[, mapping|dyn_mapping options);

Parameters

Parameter Description
manId The manager ID. See also function convManIdToInt().
dirs The parameter dirscontains the start directory for the search.
options

The parameter optionscontains a list of options:

"fromTime": time. The default value is (1.1.1970). Only includes files that are younger than specified time.

"recursive": bool. The default value is TRUE. Searches directories recursive meaning whether sub directories should be included.

"excludeDirs": dyn_string. The default value is empty. List of directories (with wild cards) that should not be searched through recursive (for example, */CVS/*).

"allIfOneYounger": bool. The default value is false. If only one file in a directory is younger than "fromTime", all files from the directory will be returned. The option does not work recursive.

"includeFiles": dyn_string. The default value is empty. A pattern to which the file names will be compared to. The files will be returned only if they correspond to the pattern. If the array is empty, all files will be considered.

Return value

The function returns 1 when it was executed successfully and in case of errors 0.

Error

Missing or invalid arguments.

Description

The function requestFileList() requests a file list from the manager with the specified manager Id.

The result is an array of mappings with following values:

  • "size": File size

  • "time": Last modification time

  • "md5": MD5 Hash

  • "name": File name

Note that the function requestFileList only works on the local system.

EXAMPLE

In the first example all files from the panels directory will be delivered and the time will not be restricted. In the second example the time will be restricted to a specific date and the option allIfOneYounger will be used. allIfOneYounger returns all files if only one file is younger than the specified date.

main()
{
  int manID;
  dyn_char managers;
  managers = makeDynChar(CTRL_MAN); //Manager type constant 
  manID = convManIdToInt(CTRL_MAN, 5);
  /*Function call with the two parameters (Manager type and
  Manager number.
  The return value is the integer that corresponds to the manager
  identifier */ 
  DebugN("ManagerID:",manID);
  dyn_string pattern;
  pattern = makeDynString("panels");
  /*The files from the directory "panels" will be delivered.
  */
  mapping opt;
  dyn_mapping l;
  l = requestFileList(manID, pattern, opt);
  /* Function call. Files from the directory "panels" will be
  delivered.
  The time will not be restricted and all directories will be
  delivered. */
  DebugN("Detailliste:", l);
  int i;
}
main()
{
  time t = setTime(t, 2010,10,04);
  int manID;
  dyn_char managers;
  managers = makeDynChar(CTRL_MAN); //Manager type constant
  manID = convManIdToInt(CTRL_MAN, 2);
  /*Function call with the two parameters (Manager type and
  Manager number.
  The return value is the integer that corresponds to the manager
  identifier */ 
  DebugN("ManagerID:", manID);
  dyn_string pattern;
  pattern = makeDynString("panels");
  /* The files from the directory "panels" will be
  delivered.*/
  mapping opt;
  opt["fromTime"] = t;
  opt["allIfOneYounger"] = TRUE;
  dyn_mapping l;
  l = requestFileList(manID, pattern, opt);
  /* Function call. Files from the directory "panels" will be
  delivered.
  If only one file is younger than 2010.10.04, all files will be
  delivered. 
  */
  DebugN("File list:", l); 
}

Assignment

File functions

Availability

CTRL