readdir bug on Mac ? Memory leak ?

Started by Pingus, September 09, 2020, 03:57:44

Previous topic - Next topic

Pingus

@IamAdmas,

Yeah I'm quite ashamed to not have noticed the need for 'closedir' (I did read the FM ;)!).
This code line was in my code since around 10 years and several published game (no joking) and never seemed to be an issue.
Coders must fight cognitive bias everyday. What was true yesterday is certainly not true today.
Truth is that I barely understand what is a byte ptr thing, to not speak about 'managed objects'. I used readdir just to know if a directory is existing which is overkill I guess.

Derron

If you wanted to know if a directory exists...

https://blitzmax.org/docs/en/api/brl/brl.filesystem/#function-filetypeint-path-

FileType:Int(path)
Get file type
Returns 0 if file at path doesn't exist, FILETYPE_FILE (1) if the file is a plain file or FILETYPE_DIR (2) if the file is a directory

Example

' filetype.bmx

SuperStrict

Print FileType(".")     ' prints 2 for directory type
Print FileType("filetype.bmx")  ' prints 1 for file type
Print FileType("notfound.file") ' prints 0 for doesn't exist


So easy peasy to check for the existence of a directory :D


bye
Ron

iWasAdam


Pingus