October 28, 2020, 10:30:24 PM

Author Topic: readdir bug on Mac ? Memory leak ?  (Read 480 times)

Offline Pingus

  • Full Member
  • ***
  • Posts: 114
Re: readdir bug on Mac ? Memory leak ?
« Reply #15 on: September 11, 2020, 12:53:48 AM »
@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.

Offline Derron

  • Hero Member
  • *****
  • Posts: 3237
Re: readdir bug on Mac ? Memory leak ?
« Reply #16 on: September 11, 2020, 07:25:17 AM »
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
Code: [Select]
' 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

Offline iWasAdam

  • Hero Member
  • *****
  • Posts: 1978
Re: readdir bug on Mac ? Memory leak ?
« Reply #17 on: September 11, 2020, 08:38:30 AM »
good call Derron :)

Offline Pingus

  • Full Member
  • ***
  • Posts: 114
Re: readdir bug on Mac ? Memory leak ?
« Reply #18 on: September 11, 2020, 02:21:51 PM »
Good to know  ;D !

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal