Studying Papyrix's code for rendering plain text ebooks...
The open routine closes the existing file if any, initializes & resets a support library, has that support library load its data propagating any errors, clears metadata, extracts a title, extracts a cache & cover filepaths, & sets a couple properties.
The close method resets that support library & the metadata.
And to calculate page number it estimates that a screenfull is 2KiB of text.
As for that support library...
1/?
The support library's constructor constructs a cache path, & carefully extracts the file's basename for its title.
To load data it carefully opens the file long enough to retrieve its size, then sets a flag & logs what its doing.
Clearing cache deletes a directory if it exists. Setting up a cache dir involves creating the directories if they don't exist. The cover is stored in that cache dir as "cover.bmp".
There's a wrapper around the GfxRenderer cover-finding util.
2/3?