07-22-2023, 07:09 AM
(07-22-2023, 01:24 AM)SMcNeill Wrote:(07-21-2023, 11:13 PM)a740g Wrote:Simplified version of direntry? Can you share it with me sometime, with a few comments about which/what you altered/expanded/simplified?(03-29-2023, 11:56 PM)bplus Wrote: Text Fetch still works after all these years in QB64pe.exe v 3.6Here is the updated version of Text Fetch that works with QB64-PE 3.8 and InForm-PE. It also has an updated and simplified version of SMcNeill 's direntry.h
I've included it on the zip I shared above.
Here's a link to it from my GitHub.
InForm-PE/examples/TextFetch/direntry.h at master · a740g/InForm-PE (github.com)
Code: (Select All)
' --- DIRENTRY STUFF ---
DECLARE LIBRARY "direntry"
' This opens a directly for reading it's contents
' IMPORTANT: Call the open_dir() wrapper instead of calling this directly. open_dir() properly null-terminates the directory string
FUNCTION __open_dir%% (dirName AS STRING)
' This reads a single directory entry. You can call this repeatedly
' It will return an empty string once all entries have been read
' "flags" and "fileSize" are output parameters (i.e. use a variable)
' If "flag" is 1 then it is a directory and 2 if it is a file
FUNCTION read_dir$ (flags AS LONG, fileSize AS LONG)
' Close the directory. This must be called before open_dir() or read_dir$() can be used again
SUB close_dir
END DECLARE
' This properly null-terminates the directory name before passing it to __load_dir()
FUNCTION open_dir%% (dirName AS STRING)
open_dir = __open_dir(dirName + CHR$(0))
END FUNCTION
' --- DIRENTRY STUFF ---
The biggest change here is that read_dir$() is now a FUNCTION and returns a string. Other than this, open_dir() returns a QB compatible bool if it fails. There is some protection for possible memory leaks if open_dir() is used without calling close_dir().