Modify

Opened 9 years ago

Closed 9 years ago

#3011 closed Bug (Fixed)

_FileListToArrayRec does not closes file handle

Reported by: MrCreatoR <mscreator@…> 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 Changed 9 years ago by Melba23

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

comment:2 Changed 9 years ago by MrCreatoR <mscreator@…>

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 Changed 9 years ago by Melba23

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 Changed 9 years ago by Melba23

  • Milestone set to 3.3.13.21
  • Owner set to Melba23
  • Resolution set to Fixed
  • Status changed from new to closed

Fixed by revision [11269] in version: 3.3.13.21

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The owner will remain Melba23.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.