1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Do not modify this file since it was automatically generated from:
%
% fileAccess.R
%
% by the Rdoc compiler part of the R.oo package.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\name{fileAccess}
\alias{fileAccess.default}
\alias{fileAccess}
\title{Checks the permission of a file or a directory}
\description{
Checks the permission of a file or a directory.
}
\usage{
\method{fileAccess}{default}(pathname, mode=0, safe=TRUE, ...)
}
\arguments{
\item{pathname}{A \code{\link[base]{character}} string of the file or the directory
to be checked.}
\item{mode}{An \code{\link[base]{integer}} (0,1,2,4), cf. \code{\link[base]{file.access}}().}
\item{safe}{If \code{\link[base:logical]{TRUE}}, the permissions are tested more carefully,
otherwise \code{\link[base]{file.access}}() is used.}
\item{...}{Not used.}
}
\value{
Returns an \code{\link[base]{integer}}; 0 if the permission exists, -1 if not.
}
\details{
In \R there is \code{\link[base]{file.access}}() for checking whether the
permission of a file.
Unfortunately, that function cannot be 100\% trusted depending on
platform used and file system queried, cf. [1].
}
\section{Symbolic links}{
This function follows symbolic links (also on Windows) and returns a
value based on the link target (rather than the link itself).
}
\examples{
# - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Current directory
# - - - - - - - - - - - - - - - - - - - - - - - - - - - -
path <- "."
# Test for existence
print(fileAccess(path, mode=0))
# Test for execute permission
print(fileAccess(path, mode=1))
# Test for write permission
print(fileAccess(path, mode=2))
# Test for read permission
print(fileAccess(path, mode=4))
# - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# A temporary file
# - - - - - - - - - - - - - - - - - - - - - - - - - - - -
pathname <- tempfile()
cat(file=pathname, "Hello world!")
# Test for existence
print(fileAccess(pathname, mode=0))
# Test for execute permission
print(fileAccess(pathname, mode=1))
# Test for write permission
print(fileAccess(pathname, mode=2))
# Test for read permission
print(fileAccess(pathname, mode=4))
file.remove(pathname)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# The 'base' package directory
# - - - - - - - - - - - - - - - - - - - - - - - - - - - -
path <- system.file(package="base")
# Test for existence
print(fileAccess(path, mode=0))
# Test for execute permission
print(fileAccess(path, mode=1))
# Test for write permission
print(fileAccess(path, mode=2))
# Test for read permission
print(fileAccess(path, mode=4))
# - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# The 'base' package DESCRIPTION file
# - - - - - - - - - - - - - - - - - - - - - - - - - - - -
pathname <- system.file("DESCRIPTION", package="base")
# Test for existence
print(fileAccess(pathname, mode=0))
# Test for execute permission
print(fileAccess(pathname, mode=1))
# Test for write permission
print(fileAccess(pathname, mode=2))
# Test for read permission
print(fileAccess(pathname, mode=4))
}
\seealso{
\code{\link[base]{file.access}}()
}
\references{
[1] R-devel thread
\emph{file.access() on network (mounted) drive on Windows Vista?}
on Nov 26, 2008.
\url{https://stat.ethz.ch/pipermail/r-devel/2008-December/051461.html}\cr
[2] Filesystem permissions, Wikipedia, 2010.
\url{https://en.wikipedia.org/wiki/Filesystem_permissions}\cr
}
\author{Henrik Bengtsson}
\keyword{IO}
\keyword{programming}
|