Search documentation of Metastatic

# Metastatic.Semantic.Domains.File (Metastatic v0.13.2)

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

Operation | Description
--- | ---
`:read` | Read file contents
`:write` | Write to file
`:append` | Append to file
`:delete` | Delete file
`:copy` | Copy file
`:move` | Move/rename file
`:exists` | Check if file exists
`:stat` | Get file metadata
`:mkdir` | Create directory
`:rmdir` | Remove directory
`:list` | List directory contents
`:open` | Open file handle
`:close` | Close 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

register_all()

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