﻿id	summary	reporter	owner	description	type	status	milestone	component	version	severity	resolution	keywords	cc
1059	Incorrect error handling in _FileListToArray()	Spiff59	Jpm	"FLTA is documented to return an @error = 4 condition when a call results in no matching files or folders.  It is improperly coded and only returns the error when called in ""Files and Folders"" mode ($iFlag = 0). If $iFlag is set to either 1 or 2, and no matches are found, an array is incorrectly returned.

The following replacement function addresses this issue, and is on average 33% faster than the current 3.3.1.1 beta version.  It is 100% compatible, and requires no modifications to the existing function header, nor to the function's helpfile entry.

This is the core logic of numerous FLTA development routines, and it has been undergoing user-testing in the field for about three months.

17-line function follows:
{{{
Func _FileListToArray2($sPath, $sFilter = ""*"", $iFlag = 0)
	Local $hSearch, $sFile, $sFileList, $sDelim = ""|""
	$sPath = StringRegExpReplace($sPath, ""[\\/]+\z"", """") & ""\"" ; ensure single trailing backslash
	If Not FileExists($sPath) Then Return SetError(1, 1, """")
	If StringRegExp($sFilter, ""[\\/:><\|]|(?s)\A\s*\z"") Then Return SetError(2, 2, """")
	If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 3, """")
	$hSearch = FileFindFirstFile($sPath & $sFilter)
	If @error Then Return SetError(4, 4, """")
	While 1
		$sFile = FileFindNextFile($hSearch)
		If @error Then ExitLoop
		If $iFlag =  1 And @extended Then ContinueLoop ; bypass folder
		If $iFlag =  2 And @extended = 0 Then ContinueLoop ; bypass file
		$sFileList &= $sDelim & $sFile
	WEnd
	FileClose($hSearch)
	If Not $sFileList Then Return SetError(4, 4, """")
	Return StringSplit(StringTrimLeft($sFileList, 1), ""|"")
EndFunc;==>_FileListToArray
}}}"	Bug	closed	3.3.1.2	AutoIt	3.3.0.0	None	Fixed		
