Core Function GetFiles

From Sputnik Wiki
Jump to: navigation, search
GetFiles ( <path>, <pattern> )

Contents

Description

Get an array of all files in a directory.

Parameters

path

The path to use.

"" means current directory.

pattern

Optional; The regex search pattern to use OR the regular text based search pattern to use

Return Value

Success: Returns array of files.

Failure: Returns empty array.

Remarks

None

Example

Get all files in current folder

$fList = GetFiles("");
foreach($fList as $file)
{
	println($file);
}

Get all files in windows folder

$fList = GetFiles("c:\\windows");
foreach($fList as $file)
{
	println($file);
}

Get all files in current folder that begin with s have none or more alphabetical chars and end with nik

$fList = GetFiles("", m/s\w*nik/);
foreach($fList as $file)
{
	println($file);
}

Get all files in current folder that end with .txt

$fList = GetFiles("", "*.txt");
foreach($fList as $file)
{
	println($file);
}

Get all files in current folder that end with .txt or end with .exe

$fList = GetFiles("", m/(\.txt)|(\.exe)/);
foreach($fList as $file)
{
	println($file);
}
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox