wrong result of ExamineDirectory

Just starting out? Need help? Post your questions and find answers here.
rvrom
New User
New User
Posts: 5
Joined: Sun Jul 27, 2014 6:25 pm

wrong result of ExamineDirectory

Post by rvrom »

I use PureBasic 5.31 (x86) on Win 8.1 and noticed that ExamineDirectory always returns positive value for non existing file with existing folder.

Code: Select all

if ExamineDirectory(0, GetCurrentDirectory(), "fake.txt")
  While NextDirectoryEntry(0)
    Debug DirectoryEntryName(0)
  Wend
  FinishDirectory(0) 
EndIf
NextDirectoryEntry works correctly and doesn't go inside a loop.
User avatar
Bisonte
Addict
Addict
Posts: 1313
Joined: Tue Oct 09, 2007 2:15 am

Re: wrong result of ExamineDirectory

Post by Bisonte »

that is the correct behaviour.

ExamineDirectory returns a value <> 0 IF the directory can be examined...

That has nothing to do with the pattern....

If the directory in your example not exist... it returns 0...
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
rvrom
New User
New User
Posts: 5
Joined: Sun Jul 27, 2014 6:25 pm

Re: wrong result of ExamineDirectory

Post by rvrom »

Bisonte wrote:that is the correct behaviour.

ExamineDirectory returns a value <> 0 IF the directory can be examined...

That has nothing to do with the pattern....

If the directory in your example not exist... it returns 0...
nope! I said that ExamineDirectory always returns positive value (<> 0) for any patterns in existing folder.

for example

Code: Select all

result = ExamineDirectory(0, GetCurrentDirectory(), "not_existing_file.txt")
; "*.txt" pattern will also receive wrong result if no txt files in the folder

Debug Str(result) ; will print positive value more than 0
please verify.
Little John
Addict
Addict
Posts: 4793
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: wrong result of ExamineDirectory

Post by Little John »

rvrom wrote:I said that ExamineDirectory always returns positive value (<> 0) for any patterns in existing folder.
So what?
As Bisonte wrote, ExamineDirectory() tests the directory, not yet any file. It checks whether the directory can be accessed, and it prepares the search for files of the given pattern.
You are confusing ExamineDirectory() with NextDirectoryEntry(), which does the actual file search.
See the manual for details.

No bug.
Last edited by Little John on Fri Jan 09, 2015 8:54 pm, edited 1 time in total.
User avatar
Demivec
Addict
Addict
Posts: 4270
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: wrong result of ExamineDirectory

Post by Demivec »

Bisonte wrote:that is the correct behaviour.

ExamineDirectory returns a value <> 0 IF the directory can be examined...

That has nothing to do with the pattern....

If the directory in your example not exist... it returns 0...
rvrom wrote:nope! I said that ExamineDirectory always returns positive value (<> 0) for any patterns in existing folder.

please verify.
@rvrom: I have verified what you said is true. It also matches exactly what is said in the help file and exactly matches Bisonte's re-statement of the help file 'that it has nothing to do with the pattern'.
PureBasic Help File -- ExamineDirectory wrote:Returns nonzero if the directory can be enumerated or zero if there was an error.
Not a bug.
rvrom
New User
New User
Posts: 5
Joined: Sun Jul 27, 2014 6:25 pm

Re: wrong result of ExamineDirectory

Post by rvrom »

Little John wrote: So what?
...
No bug.
Yep. I'm agree. This is not a bug. I was confusing by Kale's comment:
http://www.purebasic.fr/english/viewtop ... 460#p30460
Post Reply