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:

     file_path_as_absolute(x)
     file_path_sans_ext(x)

     list_files_with_exts(dir, exts, all.files = FALSE,
                          full.names = TRUE)
     list_files_with_type(dir, type, all.files = FALSE,
                          full.names = TRUE,
                          OS_subdirs = .OStype())

_A_r_g_u_m_e_n_t_s:

       x: character vector giving file paths.

     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).

OS_subdirs: a character vector with the names of OS-specific
          subdirectories to possibly include in the listing of R code
          and documentation files.  By default, the value of the
          environment variable 'R_OSTYPE', or if this is empty, the
          value of '.Platform$OS.type', is used.

_D_e_t_a_i_l_s:

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

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

     'list_files_with_exts' 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.

     'list_files_with_type' 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 according to the value of
     'OS_subdirs'.  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")
     utils::file_test("-d", dir)
     utils::file_test("-nt", file.path(dir, "R"), file.path(dir, "demo"))
     list_files_with_exts(file.path(dir, "demo"), "R")
     list_files_with_type(file.path(dir, "demo"), "demo") # the same
     file_path_sans_ext(list.files(file.path(R.home(), "modules")))

