customrealms / core

Core library for the CustomRealms runtime
https://customrealms.io/core
MIT License
36 stars 14 forks source link

feat: file read and write abstraction #47

Closed connerdouglass closed 4 months ago

connerdouglass commented 4 months ago

This PR creates a TypeScript abstraction layer around file access.

This builds on the work by @NexelOfficial in #44

Example usage:

import { Files } from '@customrealms/core';

Files.readString('server.properties'); // => entire file contents
Files.writeString('plugin-data.txt', 'score=100'); // => write a file
Files.exists('server.properties'); // => true
Files.stat('server.properties'); // => {size: 123, isDirectory: false}
Files.readdir('/path/to/folder'); // => ["server.properties", "plugins", ...]
Files.dirname('/path/to/folder'); // => "/path/to"
Files.mkdir('/path/to/folder', true); // recursively create folders
Files.remove('my-temp-file.txt'); // remove a file