Skip to main content

Overview

The files section validates the existence of required files and directories, optionally checking file permissions. This ensures critical project files are present before running your application.

Configuration

Each file check is defined by a FileCheck struct (src/config.rs:40) with the following fields:
string
required
The file or directory path to check. Can be absolute or relative to the current directory.
boolean
default:"true"
Whether the file or directory must exist. If true, validation fails when the path is not found.
boolean
default:"false"
Whether the path should be a directory. If true, validation fails if the path exists but is not a directory.
number
Unix file permissions in octal format (e.g., 0o755, 0o644). If specified, the file must have exactly these permissions.

Examples

Basic File Check

Check that a file exists:

Optional Files

Mark files as optional when they’re not always needed:

Directory Validation

Check that directories exist:

Permission Checks

Validate file permissions (useful for scripts and executables):
Permissions are specified in octal format. Common values:
  • 755: Executable files (rwxr-xr-x)
  • 644: Regular files (rw-r—r—)
  • 600: Private files (rw-------)
  • 700: Private executables (rwx------)

Real-World Examples

Common Use Cases

Configuration Files

Project Structure

Executable Scripts

Language-Specific Files

Path Resolution

Paths can be specified as:
  • Relative paths: Resolved from the current working directory
  • Absolute paths: Used as-is
  • Home directory: Use ~ for home directory expansion

Default Behavior

From the struct definition in src/config.rs:40:
  • path: Required field, no default
  • required: Defaults to true
  • is_directory: Defaults to false
  • permissions: Defaults to None (no permission check)
When required: true, validation fails if:
  • The file or directory does not exist
  • is_directory: true but the path is a file
  • is_directory: false (or omitted) but the path is a directory
  • permissions is set but the file has different permissions
Combine required: false with permission checks to validate optional files only when they exist, ensuring correct permissions if present.