User Tools

Site Tools


uphp:functions:findfirst

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
uphp:functions:findfirst [2017/03/05 12:21]
jeff
uphp:functions:findfirst [2021/09/13 05:57] (current)
Line 1: Line 1:
 ======findfirst====== ======findfirst======
 +
 <badge>WMPRO, WMMINI FW >= 1.0</badge> <badge>WMMEGA FW >= 2.0</badge> <badge>WMPRO, WMMINI FW >= 1.0</badge> <badge>WMMEGA FW >= 2.0</badge>
  
Line 5: Line 6:
  
 ====Description==== ====Description====
-<well size="sm"><html><span style="font-size:125%;color:green;">array + 
-<span style="color:black;"></html>[[findfirst]] +<well size="sm"><html> 
-<html>+<span style="font-size:125%;color:green">array 
-<span style="color:green;">string +<span style="color:black">findfirst ( 
-<span style="color:blue;">$pattern<span style="color:black;">, +<span style="color:green">string 
-<span style="color:green;">int +<span style="color:blue">$pattern<span style="color:black">, 
-<span style="color:blue;">$attributes +<span style="color:green">int 
-<span style="color:black;">)+<span style="color:blue">$attributes 
 +<span style="color:black">)
 </html></well> </html></well>
  
Line 18: Line 20:
  
 ====Parameters==== ====Parameters====
-<html><span style="color:blue;"><b>pattern</b><span style="color:black;"></html>:  Partial or full pattern such as *.* or *.cgi 
  
-<html><span style="color:blue;"><b>attributes</b><span style="color:black;"></html>:  Matching mask, leave at 255 to include allSee [[os:FAT file attributes]] for more information.+<html><b><span style="color:blue">$pattern<span style="color:black"></b></html>:  Partial or full pattern such as *.* or *.cgi
  
-====Return Value==== +<html><b><span style="color:blue">$attributes<span style="color:black"></b></html>:  Matching mask, leave at 255 to include all. See [[software:os:fat_file_system#attributes|FAT file attributes]] for more information. 
-Array of the first matching file containing the following keys and values:+ 
 +====Return Values==== 
 + 
 +<html><b><span style="color:green">Array<span style="color:black"></b></html> of the first matching file containing the following keys and values:
  
 ^KEY^TYPE^VALUE^ ^KEY^TYPE^VALUE^
-|filename|<html><span style="color:green;">string</html>|Name of the file| +|filename|<html><b><span style="color:green">string</b></html>|Name of the file| 
-|attributes|<html><span style="color:green;">int</html>|File attributes (FAT)+|attributes|<html><b><span style="color:green">int</b></html>|[[software:os:fat_file_system#attributes|FAT file attributes]]
-|filesize|<html><span style="color:green;">int</html>|File size in bytes| +|filesize|<html><b><span style="color:green">int</b></html>|File size in bytes| 
-|timestamp|<html><span style="color:green;">int</html>|FAT timestamp of last save|+|timestamp|<html><b><span style="color:green">int</b></html>|[[software:os:fat_file_system#timestamps|FAT timestamp of last save]]|
  
 ====Example==== ====Example====
 +
 +===List all files in the root directory===
 +
 <code php> <code php>
 <pre><? <pre><?
-//list all files in the root directory: +  chdir("/"); // change to the root folder 
-chdir("/"); //change to the root folder +  $arr=findfirst("*.*",255-16); // get the first entry matching any file, excluding directories 
-$arr=findfirst("*.*",255-16); //get the first entry matching any file, excluding directories +  while ($arr) { 
-while ($arr) { +    print($arr['filename']."\r\n"); 
-  print($arr['filename']."\r\n"); +    $arr=findnext(); // get another matching file 
-  $arr=findnext(); //get another matching file +  
-+?></pre>
-?> +
-</pre>+
 </code> </code>
  
-====See Also==== +====Also See====
-[[findnext()]] - Return next matching file information+
  
-[[chdir()]] - Change uPHP's current directory+[[findnext()]] - Return next matching file information (after a findfirst)
  
-[[file_exists()]] - Check if file exists+[[timefromfat()]] - Convert FAT filetime to a Linux Timestamp
  
-[[filesize()]] - Return the size of file, or the number of unread bytes in stream+[[strftime()]] - Format Linux Timestamp using format <html><b><span style="color:green">string</b></html>
  
-[[timefromfat]] - Convert a FAT filetime to native Linux timestamp+[[chdir()]] - Change the current directory 
 + 
 +[[file_exists()]] - Check if file exists
  
-[[uphp:control_structures:while]] - Flow control structure for conditional loop+[[filesize()]] - Return the size of file, or the number of unread bytes in a stream or socket
  
uphp/functions/findfirst.1488716469.txt.gz · Last modified: 2021/09/13 05:56 (external edit)