User Tools

Site Tools


uphp:functions:findfirst

This is an old revision of the document!


findfirst

WMPRO, WMMINI FW >= 1.0 WMMEGA FW >= 2.0

Start searching the current folder for files matching a pattern and attributes

Description

array findfirst ( string $pattern, int $attributes )

Begin a search to iterate through a list of files

Parameters

pattern: Partial or full pattern such as *.* or *.cgi

attributes: Matching mask, leave at 255 to include all. See FAT file attributes for more information.

Return Value

Array of the first matching file containing the following keys and values:

KEYTYPEVALUE
filenamestringName of the file
attributesintFAT file attributes
filesizeintFile size in bytes
timestampintFAT timestamp of last save

Example

<pre><?
//list all files in the root directory:
chdir("/"); //change to the root folder
$arr=findfirst("*.*",255-16); //get the first entry matching any file, excluding directories
while ($arr) {
  print($arr['filename']."\r\n");
  $arr=findnext(); //get another matching file
}
?></pre>

See Also

findnext() - Return next matching file information

timefromfat() - Convert a FAT filetime to a native Linux timestamp

strftime() - Format the passed time using the format string

chdir() - Change uPHP's current directory

file_exists() - Check if a file exists

filesize() - Return the size of a file, or the number of unread bytes in a stream

while - Flow control structure for a conditional loop

uphp/functions/findfirst.1488721567.txt.gz · Last modified: 2021/09/13 05:56 (external edit)