These functions provide a low-level interface to the computer's file system.
1 2 3 4
a character vector containing a single path name. Tilde
character vectors containing file or directory paths. Tilde
logical; should the warnings on failure be shown?
logical. Should elements of the path other than the
last be created? If true, like the Unix command
the mode to be used on Unix-alikes: it will be
logical: should the mode be restricted by the
dir.create creates the last element of the path, unless
recursive = TRUE. Trailing path separators are discarded.
The mode will be modified by the
umask setting in the same way
as for the system function
mkdir. What modes can be set is
OS-dependent, and it is unsafe to assume that more than three octal
digits will be used. For more details see your OS's documentation on the
man 2 mkdir (and not that on
the command-line utility of that name).
One of the idiosyncrasies of Windows is that directory creation may
report success but create a directory with a different name, for
dir.create("G.S.") creates ‘"G.S"’. This is
undocumented, and what are the precise circumstances is unknown (and
might depend on the version of Windows). Also avoid directory names
with a trailing space.
Sys.chmod sets the file permissions of one or more files.
It may not be supported on a system (when a warning is issued).
See the comments for
dir.create for how modes are interpreted.
Changing mode on a symbolic link is unlikely to work (nor be
necessary). For more details see your OS's documentation on the
man 2 chmod (and not that on
the command-line utility of that name). Whether this changes the
permission of a symbolic link or its target is OS-dependent (although
to change the target is more common, and POSIX does not support modes
for symbolic links: BSD-based Unixes do, though).
Sys.umask sets the
umask and returns the previous value:
as a special case
mode = NA just returns the current value.
It may not be supported (when a warning is issued and
is returned). For more details see your OS's documentation on the
man 2 umask.
How modes are handled depends on the file system, even on Unix-alikes (although their documentation is often written assuming a POSIX file system). So treat documentation cautiously if you are using, say, a FAT/FAT32 or network-mounted file system.
dir.exists returns a logical vector of
FALSE values (without names).
Sys.chmod return invisibly a logical vector
indicating if the operation succeeded for each of the files attempted.
Using a missing value for a path name will always be regarded as a
dir.create indicates failure if the directory already
showWarnings = TRUE,
dir.create will give a
warning for an unexpected failure (e.g., not for a missing value nor
for an already existing component for
recursive = TRUE).
Sys.umask returns the previous value of the
as a length-one object of class
visibility flag is off unless
See also the section in the help for
case-insensitive file systems for the interpretation of
Ross Ihaka, Brian Ripley
1 2 3 4 5 6 7