Opened 11 years ago
Closed 11 years ago
#3011 closed Bug (Fixed)
_FileListToArrayRec does not closes file handle
| Reported by: | Owned by: | Melba23 | |
|---|---|---|---|
| Milestone: | 3.3.13.21 | Component: | Standard UDFs |
| Version: | 3.3.12.0 | Severity: | None |
| Keywords: | File List Array Recursive Handle Delete Dir | Cc: |
Description
After we read files in subfolders, the folder handle is not closed, therefore it can not be deleted/changed.
Reproducing example:
#include <Array.au3> #include <File.au3> $sDir = @TempDir & '\test_dir\' $sSubDir = $sDir & 'sub_dir' DirCreate($sSubDir) FileWrite($sDir & '\test.txt', '') $aList = _FileListToArrayRec($sDir, Default, 4 + 8 + 1, 1) _ArrayDisplay($aList) MsgBox(64, '[_FileListToArrayRec]Before DirRemove', FileExists($sDir) & ', ' & FileExists($sSubDir)) ;1, 1 DirRemove($sDir, 1) MsgBox(64, '[_FileListToArrayRec]After DirRemove', FileExists($sDir) & ', ' & FileExists($sSubDir)) ;1, 1
To fix this issue, replace in function this:
; Close current search FileClose($hSearch)
with this:
; Close current search If $iHide_HS Or $iHide_Link Then DllCall($hDLL, 'int', 'FindClose', 'ptr', $hSearch) Else FileClose($hSearch) EndIf
Attachments (0)
Change History (4)
comment:1 by , 11 years ago
comment:2 by , 11 years ago
Yes, 3.3.13.20 returns 0, but the UDF should be changed, FindFirstFileW handle never closed.
; Close current search FileClose($hSearch)
should be
; Close current search If $iHide_HS Or $iHide_Link Then DllCall($hDLL, 'int', 'FindClose', 'ptr', $hSearch) Else FileClose($hSearch) EndIf
comment:3 by , 11 years ago
I have discovered why there is a difference between 3.3.12.0 and 3.3.13.20 - in the latter only asking to exclude symbolic links from the UDF return uses the DLL call, excluding hidden and system files is done using the native FileFindFirstFile function. When I change the function parameters to exclude links I get the same results as you.
Thanks for the report I will amend the UDF accordingly.
M23
comment:4 by , 11 years ago
| Milestone: | → 3.3.13.21 |
|---|---|
| Owner: | set to |
| Resolution: | → Fixed |
| Status: | new → closed |
Fixed by revision [11269] in version: 3.3.13.21

When running that reproducer script with 3.3.12.0, the second MsgBox indeed displays "1, 1" - running with 3.3.13.20 it displays "0, 0".
Can you confirm?
M23