Filesystem
filesystem
FileSystem Adapter — atomic filesystem operations with rollback.
Provides safe file/directory creation with transaction support for atomic multi-file operations used during project scaffolding.
FileSystemAdapter
Adapter for atomic filesystem operations.
Supports both single operations and transactions for multi-file atomic operations with rollback on failure.
Source code in packages/axm-init/src/axm_init/adapters/filesystem.py
create_dir(path)
Create a directory (and parents).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Directory path to create. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if successful. |
Source code in packages/axm-init/src/axm_init/adapters/filesystem.py
transaction()
Context manager for atomic multi-file operations.
On success: files are kept. On exception: all created files are rolled back.
Yields:
| Type | Description |
|---|---|
Transaction
|
Transaction object for tracked operations. |
Source code in packages/axm-init/src/axm_init/adapters/filesystem.py
write_file(path, content)
Write content to a file, creating parent directories.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Target file path. |
required |
content
|
str
|
File content to write. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if successful. |
Source code in packages/axm-init/src/axm_init/adapters/filesystem.py
Transaction
dataclass
Transaction context for atomic filesystem operations.
Tracks created files/directories for rollback on failure.
Source code in packages/axm-init/src/axm_init/adapters/filesystem.py
commit()
create_dir(path)
Create directory and track for potential rollback.
rollback()
Remove all created files and directories.
Source code in packages/axm-init/src/axm_init/adapters/filesystem.py
write_file(path, content)
Write file and track for potential rollback.