Rev 68017 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
% File src/library/tools/man/fileutils.Rd% Part of the R package, https://www.R-project.org% Copyright 1995-2013 R Core Team% Distributed under GPL 2 or later\name{fileutils}\alias{file_ext}\alias{file_path_as_absolute}\alias{file_path_sans_ext}\alias{list_files_with_exts}\alias{list_files_with_type}\title{File Utilities}\description{Utilities for listing files, and manipulating file paths.}\usage{file_ext(x)file_path_as_absolute(x)file_path_sans_ext(x, compression = FALSE)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())}\arguments{\item{x}{character vector giving file paths.}\item{compression}{logical: should compression extension \file{.gz},\file{.bz2} or \file{.xz} be removed first?}\item{dir}{a character string with the path name to a directory.}\item{exts}{a character vector of possible file extensions (excludingthe leading dot).}\item{all.files}{a logical. If \code{FALSE} (default), only visiblefiles are considered; if \code{TRUE}, all files are used.}\item{full.names}{a logical indicating whether the full paths of thefiles found are returned (default), or just the file names.}\item{type}{a character string giving the \sQuote{type} of the filesto be listed, as characterized by their extensions. Currently,possible values are \code{"code"} (R code), \code{"data"} (datasets), \code{"demo"} (demos), \code{"docs"} (R documentation), and\code{"vignette"} (vignettes).}\item{OS_subdirs}{a character vector with the names of OS-specificsubdirectories to possibly include in the listing of R code anddocumentation files. By default, the value of the environmentvariable \env{R_OSTYPE}, or if this is empty, the value of\code{\link{.Platform}$OS.type}, is used.}}\details{\code{file_ext} returns the file (name) extensions (excluding theleading dot).(Only purely alphanumeric extensions are recognized.)\code{file_path_as_absolute} turns a possibly relative file pathabsolute, performing tilde expansion if necessary. This is a wrapperfor \code{\link{normalizePath}}. Currently, \code{x} must be a singleexisting path.\code{file_path_sans_ext} returns the file paths without extensions(and the leading dot).(Only purely alphanumeric extensions are recognized.)\code{list_files_with_exts} returns the paths or names of the files indirectory \code{dir} with extension matching one of the elements of\code{exts}. Note that by default, full paths are returned, and thatonly visible files are used.\code{list_files_with_type} returns the paths of the files in \code{dir}of the given \sQuote{type}, as determined by the extensions recognizedby \R. When listing R code and documentation files, files inOS-specific subdirectories are included if present according to thevalue of \code{OS_subdirs}. Note that by default, full paths arereturned, and that only visible files are used.}\seealso{\code{\link{file.path}},\code{\link{file.info}},\code{\link{list.files}}}\examples{\donttest{dir <- file.path(R.home(), "library", "stats")list_files_with_exts(file.path(dir, "demo"), "R")list_files_with_type(file.path(dir, "demo"), "demo") # the samefile_path_sans_ext(list.files(file.path(R.home("modules"))))}}\keyword{file}