asDirectoryPath-missing-method: As Directory Path

Description Usage Arguments Value Author(s) References See Also Examples

Description

See asDirectoryPath

Usage

1
2
3
## S4 method for signature 'missing'
asDirectoryPath(path = ".", ensure = FALSE,
  strict = FALSE, ...)

Arguments

path

missing.

ensure

logical. Ensure Directory existence (TRUE) or not (FALSE, default).

strict

logical. TRUE: path must exist and be a directory; FALSE: no prior checks. If ensure = TRUE then this is automatically set to FALSE.

...

Further arguments passed to: ensureDirectory.

Value

DirectoryPath.S3. Identical to path with updated class table.

Author(s)

Janko Thyson janko.thyson@rappster.de

References

https://github.com/Rappster/filesystr

See Also

asDirectoryPath-character-method, ensureDirectory

Examples

 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
## Not run: 

##------------------------------------------------------------------------------
## Method: character
##------------------------------------------------------------------------------

## Path //
path_0 <- file.path(tempdir(), "path")

res <- asDirectoryPath(path = path_0)
res
class(res)

## Strict:
try(asDirectoryPath(path = path_0, strict = TRUE))
## --> error as 'path' does not exist yet

path <- tempfile()
file.create(path)
try(asDirectoryPath(path = path, strict = TRUE))
## --> error as 'path' is a file and not a directory 

## Note that 'ensure' overrules 'strict':
asDirectoryPath(path = path_0, ensure = TRUE, strict = TRUE)
file.exists(path_0)

## Clean up //
conditionalDelete(path = path_0, condition = tempdir())

##------------------------------------------------------------------------------
## Method: DirectoryPath.S3
##------------------------------------------------------------------------------

## Path //
path_0 <- file.path(tempdir(), "path2")

res <- asDirectoryPath(path = asDirectoryPath(path_0))
res
class(res)

## Strict:
try(res <- asDirectoryPath(path = asDirectoryPath(path_0), strict = TRUE))
## --> error as 'path' does not exist yet

## Note that 'ensure' overrules 'strict':
asDirectoryPath(path = asDirectoryPath(path_0), ensure = TRUE, strict = TRUE)
file.exists(path_0)

## Clean up //
conditionalDelete(path = path_0, condition = tempdir())


## End(Not run)

rappster/filesystr documentation built on May 26, 2019, 11:17 p.m.