Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Functions
pathutils.php File Reference

Function expands all relative parts of supplied path string thus removing things like ../../ or . More...

Functions

 copyr ($source, $dest)
 Copy a file, or recursively copy a folder and its contents. More...
 
 fullPath ($path, $dirsep=DIRECTORY_SEPARATOR)
 
 getCourseDirs ($rootDir, $contains, $excludeitems=null, $startswith=true)
 Function returns array with directories contained in folder (only first level) simmilar to getDirectories but returned items are naturally sorted. More...
 
 getDirectories ($rootDir, $contains, $excludeitems=null, $startswith=true)
 Function returns array with directories contained in folder (only first level) More...
 
 GetFiles ($startDir, $outfile, $rootDir='', $excludedirs=null, $excludefileext=null)
 
 GetFilesArray ($startDir, $rootDir='', $excludedirs=null, $excludefileext=null)
 Function to get an array with all files in a directory and subdirectories. More...
 
 getFilesOnly ($rootDir, $contains, $excludeitems=null, $startswith=true, $extension=null)
 
 getRawFiles ($startDir, &$fhandle, $rootDir='', $excludedirs=null, $excludefileext=null)
 Function returns files recursivly with appeneded relative path. More...
 
 getRawFiles2 ($startDir, &$arr, $rootDir='', $excludedirs=null, $excludefileext=null)
 
 pathDiff ($path1, $path2)
 Returns relative path from two directories with full path. More...
 
 rmdirr ($dirname)
 Delete a directory recursive with files inside. More...
 
 search_ident_by_name ($array, $name)
 Search an identifier in array. More...
 
 stripUrl ($path, $rootDir='')
 Function strips url part from css link. More...
 
 toNativePath (&$path)
 Converts direcotry separator in given path to / to validate in CC Value is passed byref hence variable itself is changed. More...
 
 toNativePath2 (&$path)
 Converts direcotry separator in given path to the one on the server platform Value is passed byref hence variable itself is changed. More...
 
 toUrlPath (&$path)
 Converts Directory separator to the / more suitable for URL. More...
 

Detailed Description

Function expands all relative parts of supplied path string thus removing things like ../../ or .

/../.

Parameters
string$path
string$dirsepCharacter that represents directory separator should be specified here. Default is DIRECTORY_SEPARATOR.
Return values
string

Function Documentation

◆ copyr()

copyr (   $source,
  $dest 
)

Copy a file, or recursively copy a folder and its contents.

Author
Aidan Lister aidan.nosp@m.@php.nosp@m..net
Version
1.0.1 @externalurl http://aidanlister.com/repos/v/function.copyr.php
Parameters
string$sourceSource path
string$destDestination path
Return values
boolReturns TRUE on success, FALSE on failure

◆ getCourseDirs()

getCourseDirs (   $rootDir,
  $contains,
  $excludeitems = null,
  $startswith = true 
)

Function returns array with directories contained in folder (only first level) simmilar to getDirectories but returned items are naturally sorted.

Parameters
string$rootDir
string$contains
array$excludeitems
bool$startswith
Return values
array

◆ getDirectories()

getDirectories (   $rootDir,
  $contains,
  $excludeitems = null,
  $startswith = true 
)

Function returns array with directories contained in folder (only first level)

Parameters
string$rootDirdirectory to look into
string$containswhich string to look for
array$excludeitemsarray of names to be excluded
bool$startswithshould the $contains value be searched only from beginning
Return values
arrayReturns array of sub-directories. In case $rootDir path is invalid it returns FALSE.

◆ GetFilesArray()

GetFilesArray (   $startDir,
  $rootDir = '',
  $excludedirs = null,
  $excludefileext = null 
)

Function to get an array with all files in a directory and subdirectories.

Parameters
string$startDir
string$rootDir
string$excludedirs
string$excludefileext
Return values
array

◆ getRawFiles()

getRawFiles (   $startDir,
$fhandle,
  $rootDir = '',
  $excludedirs = null,
  $excludefileext = null 
)

Function returns files recursivly with appeneded relative path.

Parameters
string$startDir
string$rootDir
array$excludedirs
array$excludefileext
Return values
array

◆ pathDiff()

pathDiff (   $path1,
  $path2 
)

Returns relative path from two directories with full path.

Parameters
string$path1
string$path2
Return values
string

◆ rmdirr()

rmdirr (   $dirname)

Delete a directory recursive with files inside.

Parameters
string$dirname
Return values
bool

◆ search_ident_by_name()

search_ident_by_name (   $array,
  $name 
)

Search an identifier in array.

Parameters
array$array
string$name

◆ stripUrl()

stripUrl (   $path,
  $rootDir = '' 
)

Function strips url part from css link.

Parameters
string$path
string$rootDir
Return values
string

◆ toNativePath()

toNativePath ( $path)

Converts direcotry separator in given path to / to validate in CC Value is passed byref hence variable itself is changed.

Parameters
string$path

◆ toNativePath2()

toNativePath2 ( $path)

Converts direcotry separator in given path to the one on the server platform Value is passed byref hence variable itself is changed.

Parameters
string$path

◆ toUrlPath()

toUrlPath ( $path)

Converts Directory separator to the / more suitable for URL.

Parameters
string$path