Directory list items

type DirListItem = {
  Name:      string;    // fully qualified path and file name (ex: "/docs/resume.docx")
  Type:      string;    // "FILE" or "DIR"
  Size:      number;    // the file size (integer)
  TimeStamp: time.Time; // timestamp of the item, can be converted to a JS `Date()` object via ToDate()
}

All functions that return directory lists always return an array of DirListItem objects.

Once a resulting array has been obtained, you can use the typical JavaScript ways to iterate over it, and check the various property of each one of its items.

Example 1

One way to iterate over a directory list, using a for cycle:

{
  // ...  
  // Acquire directory list
  var dirList = cli.ListDir('/docs');
  // Log each item in the list
  for (var i = 0; i < dirList.length; i++) {
    Log(dirList[i].Name);
  }
  // ...
}

Example 2

A different way to iterate over a directory list, using forEach:

{
  // ...  
  // Acquire directory list
  var dirList = cli.ListDir('/docs');
  // Log each item in the list
  dirList.forEach(myFunction);
    function myFunction(item, index, array) {
      Log(item.Name + ' [' + item.Size + ' bytes] [' + item.Type + ']');
    }
  }
  // ...
}