from moru import Sandbox
sandbox = Sandbox.create()
# Write a file
sandbox.files.write("/home/user/hello.txt", "Hello, World!")
# Read it back
content = sandbox.files.read("/home/user/hello.txt")
print(content) # Hello, World!
# List directory
entries = sandbox.files.list("/home/user")
for entry in entries:
print(f"{entry.name}: {entry.type}")
# Check if file exists
if sandbox.files.exists("/home/user/hello.txt"):
print("File exists!")
# Get file info
info = sandbox.files.get_info("/home/user/hello.txt")
print(f"Size: {info.size} bytes")
print(f"Modified: {info.modified_time}")
# Delete the file
sandbox.files.remove("/home/user/hello.txt")
sandbox.kill()