Commit Graph

9 Commits

Author SHA1 Message Date
Bob Nystrom
f1babe5ad4 feat: move File.stat to Stat.path and update all references across docs, source, and tests 2016-02-07 17:56:16 +00:00
Bob Nystrom
f112722d00 feat: add File.stat() method and Stat class for filesystem metadata queries
Implement asynchronous stat() on File class returning a new Stat object with device, inode, mode, linkCount, user, group, specialDevice, size, blockSize, and blockCount fields populated from libuv uv_fs_stat callback. Register foreign method statPath_ in module registry, bump MAX_METHODS_PER_CLASS to 10, add Stat class to io.wren with indexed field accessors, update documentation index with Stat page, and include test coverage for stat on existing file and nonexistent path.
2016-01-01 17:58:44 +00:00
Bob Nystrom
3746b56ed9 feat: add optional offset parameter to File.readBytes method
Extend File.readBytes with a second overload accepting an offset argument, allowing reads to start at any byte position from the beginning of the file. The existing single-argument variant now delegates to the new two-argument version with offset 0. Validation for the offset parameter mirrors the existing count checks, aborting on non-numeric, non-integer, or negative values. The underlying C implementation passes the offset directly to uv_fs_read, replacing the previous hardcoded zero. Documentation in the io module markdown is updated with usage examples for both signatures, and the old TODO comment about missing offset support is removed. New test files cover offset-based reads, edge cases (zero offset, past-end offset, zero count with offset), and error conditions for invalid offset arguments.
2015-12-30 16:13:19 +00:00
Bob Nystrom
0e1129bef3 docs: add full documentation for io module covering Directory, File, and Stdin classes 2015-12-30 05:56:44 +00:00
Bob Nystrom
deb833b1d8 feat: replace manual byte-buffer parsing with native C list creation in Directory.list()
The C directoryListCallback now directly builds a Wren list using wrenSetSlotNewList and wrenInsertInList, eliminating the temporary byte buffer that required manual splitting in Wren. The Wren side is simplified to a single return of the scheduler result. Additionally, the wrenCall and wrenCaptureValue functions are hardened: wrenCall discards extra temporary slots and calls with arity 0, wrenCaptureValue properly roots/unroots object values during handle creation, and the debug stack trace printer skips stub functions with NULL module pointers. A new test case verifies that wrenCall correctly ignores extra temporary slots on the stack.
2015-12-29 16:37:47 +00:00
Bob Nystrom
9b2a03c48a feat: add Directory.list() method to io module for reading directory entries
Implement a new `Directory` class with a static `list(path)` method that returns an array of filenames from the specified directory. The implementation uses a foreign function `list_(path, fiber)` that performs the actual filesystem read via libuv, collects all directory entries into a zero-byte-terminated buffer, and then splits that buffer into individual strings on the Wren side. Includes test cases for normal directory listing, listing a file path (runtime error), listing a nonexistent path (runtime error), and passing a wrong argument type (runtime error). Also bumps `MAX_CLASSES_PER_MODULE` from 3 to 4 to accommodate the new class.
2015-12-24 18:12:12 +00:00
Bob Nystrom
9e6f778147 feat: add Stdin class with readLine and async stdin read support in io module 2015-10-17 04:05:24 +00:00
Bob Nystrom
8fd9449196 feat: implement async file I/O with open/close/readBytes and scheduler error handling
Add foreign class File with static open, read, size methods and instance methods for close, size, readBytes. Implement async file operations using libuv callbacks that resume fibers on completion. Introduce schedulerResumeError and resumeError_ to propagate I/O errors as fiber errors. Add setExitCode to CLI vm for runtime error exit handling. Bump MAX_METHODS_PER_CLASS from 2 to 9 to accommodate new File methods.
2015-10-01 04:13:36 +00:00
Bob Nystrom
e4cac681a5 feat: add io module with File.size async stat and scheduler resume helpers
Introduce a new built-in "io" module exposing a File class with a static size(path) method that performs asynchronous filesystem stat via libuv. The method uses a foreign function startSize_ to initiate the stat request and resumes the calling fiber through the scheduler upon completion. Extend the scheduler with schedulerResumeDouble and schedulerResumeString to support resuming fibers with numeric or string results. Include the generated io.wren.inc source, update the Xcode project to compile io.c and io.wren.inc, register the module in modules.c, and add a test file verifying synchronous-style async size calls and error handling.
2015-09-16 14:34:49 +00:00