Package {fileaccess}


Type: Package
Title: File and Directory Access Validation
Version: 0.1.1
Description: Provides utility functions to validate read, write, execute, network, directory, and file access for local and Universal Naming Convention (UNC) network paths. Useful for pre-flight checks before file operations in data pipelines.
License: MIT + file LICENSE
Encoding: UTF-8
RoxygenNote: 7.3.3
Imports: tools
Suggests: spelling, testthat (≥ 3.0.0)
Language: en-US
Config/testthat/edition: 3
NeedsCompilation: no
Packaged: 2026-06-10 03:39:57 UTC; JSV
Author: Vaishali JS [aut, cre]
Maintainer: Vaishali JS <vaishali123.js@gmail.com>
Repository: CRAN
Date/Publication: 2026-06-17 17:40:07 UTC

fileaccess: File and Directory Access Validation

Description

Provides utility functions to validate read, write, execute, network, directory, and file access for local and UNC network paths. Useful for pre-flight checks before file operations in data pipelines.

Main functions

Author(s)

Maintainer: Vaishali JS vaishali123.js@gmail.com


Check Whether Path is a Directory

Description

Validates whether a directory exists and checks its read/write access along with content counts. Supports both local and UNC network paths.

Usage

directory.access(path)

Arguments

path

Character string. Directory path to validate.

Value

A list of class directory_access_result containing:

Examples

# Check a temporary directory
result <- directory.access(tempdir())
print(result)

# Check a path that does not exist
result <- directory.access(
  file.path(tempdir(), "no_such_folder")
)
print(result)


# UNC network path (requires network access)
directory.access("//server/share/project")



Check Whether File is Executable

Description

Validates whether a file or command can be executed. Supports both local paths and executables available in system PATH.

Usage

execute.access(path)

Arguments

path

Character string. Executable name or full path.

Value

A list of class execute_access_result containing:

Examples


# Check if Rscript is available (available on all R machines)
result <- execute.access("Rscript")
print(result)

# Check a full path to an executable
result <- execute.access(file.path(R.home("bin"), "Rscript"))
print(result)



Check Whether Path is a File

Description

Validates whether a file exists and returns detailed file information including permissions, size, type, and timestamps. Supports both local and UNC network paths.

Usage

file.access(path)

Arguments

path

Character string. File path to validate.

Value

A list of class file_access_result containing:

Examples

# Create a temp file and check it
tmp <- tempfile(fileext = ".csv")
writeLines("col1,col2\n1,2", tmp)
result <- file.access(tmp)
print(result)
unlink(tmp)

# Check a file that does not exist
result <- file.access(
  file.path(tempdir(), "missing.csv")
)
print(result)


# UNC network path (requires network access)
file.access("//server/share/data.csv")



Check Whether Path is a Network Path

Description

Validates whether a path is a network (UNC) path and whether it is accessible.

Usage

network.access(path)

Arguments

path

Character string. Network path to validate.

Value

A list of class network_access_result containing:

Examples

# A local path is not a network path
result <- network.access(tempdir())
print(result)

# Parse a UNC path structure (no network needed — just parsing)
result <- network.access("//myserver/myshare/data")
print(result)


# Real UNC network path (requires actual network access)
network.access("//server/share/data")



Check Whether File or Directory is Readable

Description

Validates whether a file or directory exists and can be accessed for reading. Supports both local and UNC network paths.

Usage

read.access(path)

Arguments

path

Character string. Full path to file or directory.

Value

A list of class read_access_result containing:

Examples

# Check a temporary directory
result <- read.access(tempdir())
print(result)

# Check an existing temporary file
tmp <- tempfile()
writeLines("hello", tmp)
result <- read.access(tmp)
print(result)
unlink(tmp)

# Check a path that does not exist
result <- read.access(file.path(tempdir(), "no_such_file.csv"))
print(result)


# UNC network path (requires network access)
read.access("//server/share/data/file.csv")



Check Whether File or Directory is Writable

Description

Validates whether a file or directory can be accessed for writing. Supports both local and UNC network paths.

Usage

write.access(path)

Arguments

path

Character string. Full path to file or directory.

Value

A list of class write_access_result containing:

Examples

# Check a temporary directory
result <- write.access(tempdir())
print(result)

# Check an existing temporary file
tmp <- tempfile()
writeLines("hello", tmp)
result <- write.access(tmp)
print(result)
unlink(tmp)

# Check a new file path that does not exist yet
result <- write.access(file.path(tempdir(), "newfile.csv"))
print(result)


# UNC network path (requires network access)
write.access("//server/share/output/results.csv")