or run

tessl search
Log in

Version

Files

tile.json

task.mdevals/scenario-6/

Permission Validator

A utility that validates file and directory access permissions in a memory-based filesystem.

Capabilities

Check file existence

  • When given a file path that exists, the validator confirms existence without throwing an error @test
  • When given a file path that does not exist, the validator throws an error with code 'ENOENT' @test

Check read permissions

  • When a file has read permissions set (mode 0o444), the validator confirms read access @test
  • When a file lacks read permissions (mode 0o000), the validator throws an error with code 'EACCES' @test

Check write permissions

  • When a file has write permissions set (mode 0o222), the validator confirms write access @test
  • When a file lacks write permissions (mode 0o444), the validator throws an error with code 'EACCES' @test

Validate directories

  • When a directory exists and has appropriate permissions, the validator confirms access @test
  • When a directory exists but lacks permissions (mode 0o000), the validator throws an error with code 'EACCES' @test

Implementation

@generates

API

/**
 * Validates file or directory access permissions.
 *
 * @param {string} path - The path to validate
 * @param {number} mode - The permission mode to check (use constants like F_OK, R_OK, W_OK)
 * @throws {Error} Throws an error with code 'ENOENT' if path doesn't exist
 * @throws {Error} Throws an error with code 'EACCES' if access is denied
 */
function validateAccess(path, mode) {
  // Implementation here
}

module.exports = { validateAccess };

Dependencies { .dependencies }

metro-memory-fs { .dependency }

Provides in-memory filesystem implementation with permission checking support.

@satisfied-by