FS_ListDirectory

function

Library: File system utilities (OMFSYS legacy)
Include: omfsys.xin

Declaration
define external function FS_ListDirectory
                value      stream  pathname
   into         modifiable stream  directory
   status       modifiable stream  statusvalue 


Purpose

The omfsys library has been deprecated and will be removed from a future version of the language. Use omvfs instead.

This function retrieves the contents list of the specified directory.

Example:

  ; fs-listdirectory.xom
  include "omfsys.xin"
   process
      local stream  current-dir variable initial-size 1 initial {"C:\omprogs"}
      local stream  dir-list variable initial-size 0
      local stream  error-status  variable initial-size 1
         
      FS_ListDirectory current-dir into dir-list status error-status
  
      repeat over dir-list
          do when file (current-dir || "/" || dir-list) is directory
              output "%_" || "<DIR> " 
                          || dir-list || "%n"
          else
              output "%_" || "<file>" 
                          || dir-list || "%n"
          done
      again
  ; Output lists all directories "<DIR>" and files "<file>" in current-dir.

Input argument:

Output arguments:

Wildcards are allowed in the directory parameter.

For example, the following line will cause FS_ListDirectory to find all files ending in ".xom" within "C:\omprogs"

  local stream pathname initial {"C:\omprogs\*.xom"}

The following line will cause FS_ListDirectory to find all files beginning with "om" within "C:\omprogs"

  local stream pathname initial {"C:\omprogs\om*"}

Note that "pathname" must reference a valid directory path. Also, "dot" directory entries are not returned.