StringFile - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: Expanding Horizons (Libraries) (https://qb64phoenix.com/forum/forumdisplay.php?fid=21) +---- Forum: a740g (https://qb64phoenix.com/forum/forumdisplay.php?fid=55) +---- Thread: StringFile (/showthread.php?tid=2190) |
StringFile - a740g - 11-21-2023 File I/O like routines for memory loaded files. The StringFile library can be used for dealing with files that are completely loaded in memory. Since it uses QB64 strings as a backing buffer, no explicit memory management (i.e. freeing) is required. No need to worry about opening, closing, or freeing anything. Everything is nicely cleaned up when it goes out of scope. API List: I actually have a C version of this, but I made a pure QB64 version for something that I am working on. Sorry, there is no demo for this one. There is some test code in StringFile.bas. Most of it is very simple and straightforward. Notes: 1. Unlike QB64 file I/O stuff, StringFile is 0 based. Meaning the first byte in the file is at position 0. This helps a lot when porting over code from languages like C. Stuff like Code: (Select All) byte = fgetc(f); Code: (Select All)
2. StringFile is optimized for little-endian. So, if you are loading big-endian stuff, ensure you do the necessary byte swaps. 3. Just because the whole file is in memory, you are not allowed to be careless. StringFile will yell at you (read throw errors) if you do stuff like reading past the end of the file or positioning the cursor to a non-existent location. RE: StringFile - grymmjack - 12-05-2023 Cool. Is this in Toolbox64? RE: StringFile - a740g - 12-05-2023 (12-05-2023, 05:27 AM)grymmjack Wrote: Cool. Is this in Toolbox64? Yep. It is. I am using this in GIFPlay too. RE: StringFile - RhoSigma - 12-05-2023 (12-05-2023, 09:04 AM)a740g Wrote:(12-05-2023, 05:27 AM)grymmjack Wrote: Cool. Is this in Toolbox64? Right, and who wants the "Luxury Version" of this can take The Simplebuffer System (Read Docs) from my Libraries Collection |