Getting Started Documentation Glish Learn More Programming Contact Us
Version 1.9 Build 1556
News FAQ
Search Home


next up previous contents index
Next: os.ls - Function Up: os - Tool Previous: os.fileexists - Function


os.dir - Function



Package utility
Module misc
Tool os


return a vector of strings with directory listing


Synopsis
dir(directoryname, pattern, types, all, follow)


Description
Get a vector of strings containing the names of files in the given directory. Other arguments can be given to select specific files. To simply list the files in a human-readable format, use dos.ls() instead.
pattern can be given to select specific file names using a file name pattern as given in a shell. E.g. pattern='*.g' to get all .g files.
By default no name selection is done.
types can be given to select on a file (access) types. It is a string containing zero or more letters indicating the required type(s). There are two groups of types:
  • r d s indicate regular file, directory, resp. symbolic link.
  • R W X indicate readable, writable, resp. executable.
If one or more letters from a group are given, only such files will be selected.
By default no type selection is done.
all can be given to indicate that file names starting with a . should be selected.
By default they are not selected.
Note that even if a pattern '.*' is given, all=T should be given to get those files.
If follow==T symbolic links will be followed. In that case using 's' in the types argument makes no sense.



Arguments

directoryname in directory name
    Allowed: string
    Default: '.'
pattern in file name pattern
    Allowed: string
    Default: ''
types in which types?
    Allowed: string
    Default: ''
all in also dot files?
    Allowed: bool
    Default: F
follow in follow symlink?
    Allowed: bool
    Default: T


Example
  dos.dir (pattern='*.pg')   #get all files ending in .pg
  dos.dir (types='rX')       #get all regular executable files
  v:=dos.dir ('~/aips++/test', types='d')    # get directories
  for (nm in v) {                            # (potential tables)
    if (dos.filetype(spaste('~/aips++/test/',nm)) == 'Table') {
      print nm;                                      #show tables
    }
  }



Returns
vector of strings or fail




next up previous contents index
Next: os.ls - Function Up: os - Tool Previous: os.fileexists - Function   Contents   Index
Please send questions or comments about AIPS++ to aips2-request@nrao.edu.
Copyright © 1995-2000 Associated Universities Inc., Washington, D.C.

Return to AIPS++ Home Page
2006-10-15