Skip to content

Add runnable examples for path-based and descriptor-based file I/O #377

Description

@LunaStev

Tracked by #375.

Problem

Current file APIs are easy to misuse. fs_read_all accepts a path, destination pointer, and capacity, while io_read accepts a file descriptor. Existing examples do not make that boundary obvious.

Scope

Add small runnable examples and Wave corpus fixtures for:

  • Opening and closing a file with std::fs::file.
  • Reading a path into a caller-owned byte array with fs_read_all.
  • Reading an already-open descriptor with std::io::fd::io_read.
  • Handling negative return values.
  • Reporting the number of bytes read without treating it as a string length.

Use only current APIs. API renaming belongs to #375 and its design follow-ups.

Completion criteria

  • Every example compiles with the current compiler and installed std layout.
  • At least one fixture executes on supported hosted Linux CI.
  • Buffer capacity and returned byte count are checked.
  • Examples do not import private transitive symbols.
  • Documentation states that fs_read_all does not allocate or return str.

Metadata

Metadata

Assignees

Labels

documentationIssues or enhancements related to the documentation.good first issueIssues that are good for newcomers or first-time contributors.needs testingIssues that require additional testing or verification.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions