Notes
Filenames with multiple Extensions: only the last extensions is saved as extensions
eg: aaa.bbb.ccc results in File=aaa.bbb and Extension=ccc
Filenames are stored in the same case as the are stored in the filesystem
sFilter is only applied to files.
*/
if ( !defined( "INCLUCDED_DIR" ) )
{
define( "INCLUCDED_DIR", TRUE );
Class CDir
{
var $aFiles;
Function CDir()
{
$this->Init();
}
Function Init()
{
unset( $this->aFiles );
$this->aFiles = array();
}
// Read
// sPath path eg. "../xx/yy/" (note the last "/"
// sInclude regular expression for filtering path- and filenames
// fRecursive true/false: go down the whole structure
// fFiles result set will contain entries which are files
// fDirectory result set will contain entries which are directories
// sRoot Root-Path. Will be appended to the entries.
// sExclude regular expression for filtering path- and filenames
Function Read( $sPath, $sInclude = "", $fRecursive = false, $fFiles = true, $fDirectories = true, $sRoot = "", $sExclude = "" )
{
$oHandle = opendir( $sPath );
while ( $sFilename = readdir( $oHandle ) )
{
$fInsert = true;
Function FileName( $aFile )
{
$sBuffer = $this->DirectoryName( $aFile );
if ( $this->GetIsDirectory( $aFile ) )
$sBuffer .= "/";
return( $sBuffer );
}
// DirectoryName returns the same as FileName, but without a ending "/" for Directories.
Function DirectoryName( $aFile )
{
$sBuffer = $this->GetExtension( $aFile );
if ( !empty( $sBuffer ) )
$sBuffer = "." . $sBuffer;
$sBuffer = $this->GetFile( $aFile ) . $sBuffer;
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.