fileutils               package:tools               R Documentation

_F_i_l_e _U_t_i_l_i_t_i_e_s

_D_e_s_c_r_i_p_t_i_o_n:

     Utilities for testing and listing files, and manipulating file
     paths.

_U_s_a_g_e:

     filePathAsAbsolute(x)
     filePathSansExt(x)
     fileTest(op, x, y)
     listFilesWithExts(dir, exts, all.files = FALSE, full.names = TRUE)
     listFilesWithType(dir, type, all.files = FALSE, full.names = TRUE)

_A_r_g_u_m_e_n_t_s:

     x,y: character vectors giving file paths.

      op: a character string specifying the test to be performed. Unary
          tests (only 'x' is used) are '"-f"' (existence and not being
          a directory) and '"-d"' (existence and directory); binary
          tests are '"-nt"' (newer than, using the modification dates)
          and '"-ot"'.

     dir: a character string with the path name to a directory.

    exts: a character vector of possible file extensions.

all.files: a logical.  If 'FALSE' (default), only visible files are
          considered; if 'TRUE', all files are used.

full.names: a logical indicating whether the full paths of the files
          found are returned (default), or just the file names.

    type: a character string giving the "type" of the files to be
          listed, as characterized by their extensions.  Currently,
          possible values are '"code"' (R code), '"data"' (data sets),
          '"demo"' (demos), '"docs"' (R documentation), and
          '"vignette"' (vignettes).

_D_e_t_a_i_l_s:

     'filePathAsAbsolute' turns a possibly relative file path absolute,
     performing tilde expansion if necessary.  Currently, only a single
     existing path can be given.

     'filePathSansExt' returns the file paths without extensions. (Only
     purely alphanumeric extensions are recognized.)

     'fileTest' performs shell-style file tests.  Note that
     'file.exists' only tests for existence ('test -e' on some systems)
     but not for not being a directory.

     'listFilesWithExts' returns the paths or names of the files in
     directory 'dir' with extension matching one of the elements of
     'exts'.  Note that by default, full paths are returned, and that
     only visible files are used.

     'listFilesWithType' returns the paths of the files in 'dir' of the
     given "type", as determined by the extensions recognized by R. 
     When listing R code and documentation files, files in OS-specific
     subdirectories are included if present.  Note that by default,
     full paths are returned, and that only visible files are used.

_S_e_e _A_l_s_o:

     'file.path', 'file.info', 'list.files'

_E_x_a_m_p_l_e_s:

     dir <- file.path(R.home(), "library", "stats")
     fileTest("-d", dir)
     fileTest("-nt", file.path(dir, "R"), file.path(dir, "demo"))
     listFilesWithExts(file.path(dir, "demo"), "R")
     listFilesWithType(file.path(dir, "demo"), "demo") # the same
     filePathSansExt(list.files(file.path(R.home(), "modules")))

