| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/file.R |
| 3 |
\name{file_info} |
| 4 |
\alias{file_info} |
| 5 |
\alias{file_size} |
| 6 |
\title{Query file metadata} |
| 7 |
\usage{ |
| 8 |
file_info(path, fail = TRUE, follow = FALSE) |
| 9 |
|
| 10 |
file_size(path, fail = TRUE) |
| 11 |
} |
| 12 |
\arguments{ |
| 13 |
\item{path}{A character vector of one or more paths.} |
| 14 |
|
| 15 |
\item{fail}{Should the call fail (the default) or warn if a file cannot be |
| 16 |
accessed.} |
| 17 |
|
| 18 |
\item{follow}{If \code{TRUE}, symbolic links will be followed (recursively) and |
| 19 |
the results will be that of the final file rather than the link.} |
| 20 |
} |
| 21 |
\value{ |
| 22 |
A data.frame with metadata for each file. Columns returned are as follows. |
| 23 |
\item{path}{The input path, as a \code{\link[=fs_path]{fs_path()}} character vector.} |
| 24 |
\item{type}{The file type, as a factor of file types.} |
| 25 |
\item{size}{The file size, as a \code{\link[=fs_bytes]{fs_bytes()}} numeric vector.} |
| 26 |
\item{permissions}{The file permissions, as a \code{\link[=fs_perms]{fs_perms()}} integer vector.} |
| 27 |
\item{modification_time}{The time of last data modification, as a \link{POSIXct} datetime.} |
| 28 |
\item{user}{The file owner name - as a character vector.} |
| 29 |
\item{group}{The file group name - as a character vector.} |
| 30 |
\item{device_id}{The file device id - as a numeric vector.} |
| 31 |
\item{hard_links}{The number of hard links to the file - as a numeric vector.} |
| 32 |
\item{special_device_id}{The special device id of the file - as a numeric vector.} |
| 33 |
\item{inode}{The inode of the file - as a numeric vector.} |
| 34 |
\item{block_size}{The optimal block for the file - as a numeric vector.} |
| 35 |
\item{blocks}{The number of blocks allocated for the file - as a numeric vector.} |
| 36 |
\item{flags}{The user defined flags for the file - as an integer vector.} |
| 37 |
\item{generation}{The generation number for the file - as a numeric vector.} |
| 38 |
\item{access_time}{The time of last access - as a \link{POSIXct} datetime.} |
| 39 |
\item{change_time}{The time of last file status change - as a \link{POSIXct} datetime.} |
| 40 |
\item{birth_time}{The time when the inode was created - as a \link{POSIXct} datetime.} |
| 41 |
} |
| 42 |
\description{ |
| 43 |
Compared to \code{\link[=file.info]{file.info()}} the full results of a \code{stat(2)} system call are |
| 44 |
returned and some columns are returned as S3 classes to make manipulation |
| 45 |
more natural. On systems which do not support all metadata (such as Windows) |
| 46 |
default values are used. |
| 47 |
} |
| 48 |
\examples{ |
| 49 |
\dontshow{.old_wd <- setwd(tempdir())} |
| 50 |
write.csv(mtcars, "mtcars.csv") |
| 51 |
file_info("mtcars.csv") |
| 52 |
|
| 53 |
# Files in the working directory modified more than 20 days ago |
| 54 |
files <- file_info(dir_ls()) |
| 55 |
files$path[difftime(Sys.time(), files$modification_time, units = "days") > 20] |
| 56 |
|
| 57 |
# Cleanup |
| 58 |
file_delete("mtcars.csv") |
| 59 |
\dontshow{setwd(.old_wd)} |
| 60 |
} |
| 61 |
\seealso{ |
| 62 |
\code{\link[=dir_info]{dir_info()}} to display file information for files in a given |
| 63 |
directory. |
| 64 |
} |