Modify

Opened 8 years ago

Closed 8 years ago

#2045 closed Feature Request (Rejected)

FileFindNextFile advanced parameter

Reported by: money Owned by:
Milestone: Component: AutoIt
Version: Severity: None
Keywords: Cc:

Description

 FileFindNextFile
 --------------------------------------------------------------------------------
 Returns a filename according to a previous call to FileFindFirstFile.

 FileFindNextFile ( search, [advanced = 0] )

 Parameters

    search - The search handle, as returned by FileFindFirstFile.

    advanced
      0 = returns a filename according to a previous call to FileFindFirstFile.

      1 = returns an array containing the filename and extended information.


	When using the "advanced" parameter the information is returned in an array
	+ with extended information:

        $array[0] = filename
        $array[1] = 8.3 filename (same as FileGetShortname(file))
        $array[2] = size of the file (same as FileGetSize(file))
        $array[3] = file attribute (same as FileGetAttrib(file))
        $array[4] = date modified (same as FileGetTime(file, 0, 1) )
        $array[5] = date created (same as FileGetTime(file, 1, 1))
        $array[6] = date accessed (same as FileGetTime(file, 2, 1))

The advanced parameter would remove the need to use 6 additional File* calls to get
+ the information we're after and add negligible time because this would be handled
+ internally by AutoIt.

Basically what FindFirstFile/FindNextFile returns, except the values correspond
+ with the other File* functions. e.g. FileGetAttrib()

Of course this would be fully backwords compatible with existing scripts
+ If the advanced parameter is 0 (default) then returns just the filename.


Here we have decent speed with FileFind* used alone, but once we need to dig out
+ additional information, things start to noticably slow down.

$time = TimerInit()
_Example(@WindowsDir, False)
ConsoleWrite("name only - completed (ms): "& Round(TimerDiff($time), 4)  &@lf)

$time = TimerInit()
_Example(@WindowsDir, True)
ConsoleWrite("extended - completed (ms): "& Round(TimerDiff($time), 4)  &@lf)


Func _Example($sPath, $bExtended = False)
	Local $hFind = FileFindFirstFile($sPath & "\*.*")


	Local $aFile[7], $sFile

	If @error Or $hFind = -1 Then Return SetError(1, 0, 0)

	While 1

		$sFile = FileFindNextFile($hFind)
		If @error Or $sFile = -1 Then ExitLoop

		; skip folders
		If Not @extended Then

			$aFile[0] = $sFile

			; These 6 functions significantly impact search time.
			; FileFindNextFile with advanced parameter would
			; remove the need for these additional file calls
			If $bExtended Then
				$aFile[1] = FileGetShortName($sPath &"\"& $sFile)
				$aFile[2] = FileGetSize($sPath &"\"& $sFile)
				$aFile[3] = FileGetAttrib($sPath &"\"& $sFile)
				$aFile[4] = FileGetTime($sPath &"\"& $sFile, 0, 1)
				$aFile[5] = FileGetTime($sPath &"\"& $sFile, 1, 1)
				$aFile[6] = FileGetTime($sPath &"\"& $sFile, 2, 1)
			EndIf

;~ 			ConsoleWrite( _
;~ 			'-----------------------------'&@LF& _
;~ 			'name: '& $aFile[0] &@LF& _
;~ 			'short name: '& $aFile[1] &@LF& _
;~ 			'size: '& $aFile[2] &@LF& _
;~ 			'attribute: '& $aFile[3] &@LF& _
;~ 			'date modified: '& $aFile[4] &@LF& _
;~ 			'date created: '& $aFile[5] &@LF& _
;~ 			'date accessed: '& $aFile[6] &@LF)
		EndIf

	WEnd

	FileClose($hFind)
EndFunc

Attachments (0)

Change History (2)

comment:1 Changed 8 years ago by TicketCleanup

  • Version 3.3.6.1 deleted

Automatic ticket cleanup.

comment:2 Changed 8 years ago by Valik

  • Resolution set to Rejected
  • Status changed from new to closed

You demonstrate in your request that you can obtain the data you want. There is no need for the feature to be built-in. "But it's faster" is not a reason.

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 ticket will remain with no owner.
Author


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

 
Note: See TracTickets for help on using tickets.