package mantra.io

File

CLASS public class

High-performance filesystem reader and writer using native C stdio and atomic descriptors.

🏗️ Constructor Summary

Constructor Signature
def __init__(self, path: String)

⚙️ Method Summary

Modifier & Return Type Method Signature Description
String read_all() Reads complete file contents into a heap string.
Bool write_all(content: String) Overwrites target file atomically with text content.
Bool exists() Returns True if the path exists on disk.

🔍 Detailed Method Specifications

pub def read_all() -> String
Reads complete file contents into a heap string.
pub def write_all(content: String) -> Bool
Overwrites target file atomically with text content.
pub def exists() -> Bool
Returns True if the path exists on disk.

💡 Example Usage

file_example.mantra
let f = File("config.json")
if f.exists():
    let content = f.read_all()
    print(content)