Page 1 of 1
wrong result of ExamineDirectory
Posted: Fri Jan 09, 2015 1:08 am
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.
Re: wrong result of ExamineDirectory
Posted: Fri Jan 09, 2015 2:19 am
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...
Re: wrong result of ExamineDirectory
Posted: Fri Jan 09, 2015 8:38 pm
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.
Re: wrong result of ExamineDirectory
Posted: Fri Jan 09, 2015 8:51 pm
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, Examine
Directory() 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.
Re: wrong result of ExamineDirectory
Posted: Fri Jan 09, 2015 8:51 pm
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.
Re: wrong result of ExamineDirectory
Posted: Sat Jan 10, 2015 1:33 pm
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