Lua File: add readWhole()

Open Beginner friendly
#2,667 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
69/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
cpp, lua
Domain
backend

Research direction

Start by reading the File and Slice APIs and the five src:read(src:size()) call sites in src/supportpsx/binffi.lua; the Text viewer use in issue #2585 is another example. Add a File:readWhole() method that returns a Slice, with behavior defined for non-seekable or failed files. Done when callers can use the shared method and its failure behavior is clear.

Written by the indexing model from the issue text.

Description

Reading a whole file into a Slice is spelled out by hand in several places: src:read(src:size()) five times in src/supportpsx/binffi.lua, and readAt(f:size(), 0) in the Text viewer of #2585. A File:readWhole() returning the Slice (callers that want a string still tostring it) would give them one name, and a place to define what it does on a non-seekable or failed file.

Raised by @nicolasnoble in review of the TextTable viewer.

Dominant language
C++
Stars
1k
Forks
158
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from grumpycoders/pcsx-redux

All issues in grumpycoders/pcsx-redux

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.