Metastatic.Semantic.Domains.File (Metastatic v0.10.4)

View Source

File I/O operation patterns for semantic enrichment.

This module defines patterns for detecting file operations across multiple languages and file handling libraries. Patterns are registered with the Metastatic.Semantic.Patterns registry at module load time.

Supported Libraries

Elixir

  • File - Standard library file operations
  • Path - Path manipulation
  • IO - Input/output operations

Python

  • builtins - open(), read(), write()
  • os - OS-level file operations
  • pathlib - Object-oriented path operations
  • shutil - High-level file operations

Ruby

  • File - Standard library file operations
  • FileUtils - File utility methods
  • IO - Input/output operations

JavaScript

  • fs - Node.js file system module
  • fs/promises - Promise-based fs operations
  • path - Path manipulation

File Operations

OperationDescription
:readRead file contents
:writeWrite to file
:appendAppend to file
:deleteDelete file
:copyCopy file
:moveMove/rename file
:existsCheck if file exists
:statGet file metadata
:mkdirCreate directory
:rmdirRemove directory
:listList directory contents
:openOpen file handle
:closeClose file handle

Pattern Structure

Each pattern is a tuple of {pattern, spec} where:

  • pattern - String or Regex to match function names
  • spec - Map with operation details:
    • :operation - The file operation type
    • :framework - The file library identifier
    • :extract_target - Strategy for extracting file path

Summary

Functions

Registers all file patterns for all languages.

Functions

register_all()

@spec register_all() :: :ok

Registers all file patterns for all languages.

Called automatically when the module is loaded. Can also be called manually to re-register patterns (e.g., after clearing).