file.access: Check Whether Path is a File

View source: R/file_access.R

file.accessR Documentation

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:

  • path - Normalized file path

  • exists - TRUE/FALSE

  • can_read - TRUE/FALSE

  • can_write - TRUE/FALSE

  • can_execute - TRUE/FALSE

  • locked - TRUE/FALSE

  • size_mb - File size formatted

  • type - Detected file type description

  • modified - Last modified timestamp

  • status - Overall status message

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")



fileaccess documentation built on June 18, 2026, 1:06 a.m.