Open Journal Systems  3.3.0
System Class Reference

Static Public Member Functions

static _parseArgs ($argv, $short_options, $long_options=null)
 
static _removeTmpFiles ()
 
static & cat ($args)
 
static find ($args)
 
static mkDir ($args)
 
static mktemp ($args=null)
 
static rm ($args)
 
static tmpdir ()
 
static which ($program, $fallback=false)
 

Static Protected Member Functions

static _dirToStruct ($sPath, $maxinst, $aktinst=0, $silent=false)
 
static _multipleToStruct ($files)
 
static raiseError ($error)
 

Detailed Description

Definition at line 58 of file System.php.

Member Function Documentation

◆ _dirToStruct()

static System::_dirToStruct (   $sPath,
  $maxinst,
  $aktinst = 0,
  $silent = false 
)
staticprotected

Creates a nested array representing the structure of a directory

System::_dirToStruct('dir1', 0) => Array ( [dirs] => Array ( [0] => dir1 )

[files] => Array ( [0] => dir1/file2 [1] => dir1/file3 ) )

Parameters
string$sPathName of the directory
integer$maxinstmax. deep of the lookup
integer$aktinststarting deep of the lookup
bool$silentif true, do not emit errors.
Returns
array the structure of the dir

Definition at line 141 of file System.php.

References raiseError().

Referenced by _multipleToStruct(), and find().

◆ _multipleToStruct()

static System::_multipleToStruct (   $files)
staticprotected

Creates a nested array representing the structure of a directory and files

Parameters
array$filesArray listing files and dirs
Returns
array
See also
System::_dirToStruct()

Definition at line 184 of file System.php.

References _dirToStruct().

Referenced by rm().

◆ _parseArgs()

static System::_parseArgs (   $argv,
  $short_options,
  $long_options = null 
)
static

returns the commandline arguments of a function

Parameters
string$argvthe commandline
string$short_optionsthe allowed option short-tags
string$long_optionsthe allowed option long-tags
Returns
array the given options and there values

Definition at line 68 of file System.php.

References Console_Getopt\getopt2().

Referenced by mkDir(), mktemp(), and rm().

◆ _removeTmpFiles()

static System::_removeTmpFiles ( )
static

Remove temporary files created my mkTemp. This function is executed at script shutdown time

Definition at line 445 of file System.php.

References $GLOBALS, and rm().

◆ cat()

static& System::cat (   $args)
static

Concatenate files

Usage: 1) $var = System::cat('sample.txt test.txt'); 2) System::cat('sample.txt test.txt > final.txt'); 3) System::cat('sample.txt test.txt >> final.txt');

Note: as the class use fopen, urls should work also

Parameters
string$argsthe arguments
Returns
boolean true on success

Definition at line 323 of file System.php.

References raiseError().

◆ find()

static System::find (   $args)
static

The "find" command

Usage:

System::find($dir); System::find("$dir -type d"); System::find("$dir -type f"); System::find("$dir -name *.php"); System::find("$dir -name *.php -name *.htm*"); System::find("$dir -maxdepth 1");

Params implemented: $dir -> Start the search at this directory -type d -> return only directories -type f -> return only files -maxdepth <n> -> max depth of recursion -name <pattern> -> search pattern (bash style). Multiple -name param allowed

Parameters
mixedEither array or string with the command line
Returns
array Array of found files

Definition at line 566 of file System.php.

References _dirToStruct().

◆ mkDir()

static System::mkDir (   $args)
static

Make directories.

The -p option will create parent directories

Parameters
string$argsthe name of the director(y|ies) to create
Returns
bool True for success

Definition at line 254 of file System.php.

References _parseArgs(), PEAR\isError(), and raiseError().

Referenced by mktemp().

◆ mktemp()

static System::mktemp (   $args = null)
static

Creates temporary files or directories. This function will remove the created files when the scripts finish its execution.

Usage: 1) $tempfile = System::mktemp("prefix"); 2) $tempdir = System::mktemp("-d prefix"); 3) $tempfile = System::mktemp(); 4) $tempfile = System::mktemp("-t /var/tmp prefix");

prefix -> The string that will be prepended to the temp name (defaults to "tmp"). -d -> A temporary dir will be created instead of a file. -t -> The target dir where the temporary (file|dir) will be created. If this param is missing by default the env vars TMP on Windows or TMPDIR in Unix will be used. If these vars are also missing c:\windows\temp or /tmp will be used.

Parameters
string$argsThe arguments
Returns
mixed the full path of the created (file|dir) or false
See also
System::tmpdir()

Definition at line 395 of file System.php.

References $GLOBALS, _parseArgs(), PEAR\isError(), mkDir(), raiseError(), PEAR\registerShutdownFunc(), and tmpdir().

Referenced by OS_Guess\_detectGlibcVersion().

◆ raiseError()

static System::raiseError (   $error)
staticprotected

Output errors with PHP trigger_error(). You can silence the errors with prefixing a "@" sign to the function call: @System::mkdir(..);

Parameters
mixed$errora PEAR error or a string with the error message
Returns
bool false

Definition at line 109 of file System.php.

References PEAR\isError().

Referenced by _dirToStruct(), cat(), mkDir(), mktemp(), and rm().

◆ rm()

static System::rm (   $args)
static

The rm command for removing files. Supports multiple files and dirs and also recursive deletes

Parameters
string$argsthe arguments for rm
Returns
mixed PEAR_Error or true for success

@access public

Definition at line 210 of file System.php.

References _multipleToStruct(), _parseArgs(), PEAR\isError(), and raiseError().

Referenced by _removeTmpFiles().

◆ tmpdir()

static System::tmpdir ( )
static

Get the path of the temporal directory set in the system by looking in its environments variables. Note: php.ini-recommended removes the "E" from the variables_order setting, making unavaible the $_ENV array, that s why we do tests with _ENV

Returns
string The temporary directory on the system

Definition at line 463 of file System.php.

Referenced by mktemp().

◆ which()

static System::which (   $program,
  $fallback = false 
)
static

The "which" command (show the full path of a command)

Parameters
string$programThe command to search for
mixed$fallbackValue to return if $program is not found
Returns
mixed A string with the full path or false if not found
Author
Stig Bakken ssb@p.nosp@m.hp.n.nosp@m.et

Definition at line 495 of file System.php.


The documentation for this class was generated from the following file: