System
[ class tree: System ] [ index: System ] [ all elements ]

Class: System

Source Location: /PEAR-1.3.5/System.php

Class Overview


System offers cross plattform compatible system functions


Author(s):

Version:

  • $Revision: 1.36 $

Methods


Inherited Variables

Inherited Methods


Class Details

[line 55]
System offers cross plattform compatible system functions

Static functions for different operations. Should work under Unix and Windows. The names and usage has been taken from its respectively GNU commands. The functions will return (bool) false on error and will trigger the error with the PHP trigger_error() function (you can silence the error by prefixing a '@' sign after the function call).

Documentation on this class you can find in: http://pear.php.net/manual/

Example usage: if (!@System::rm('-r file1 dir1')) { print "could not delete file1 or dir1"; }

In case you need to to pass file names with spaces, pass the params as an array:

System::rm(array('-r', $file1, $dir1));



[ Top ]


Method Detail

cat   [line 278]

boolean &cat( string $args)

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 (test that)

  • Return: true on success
  • Access: public

Parameters:

string   $args   —  the arguments

[ Top ]

find   [line 486]

array find( mixed $args)

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 implmented: $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

  • Return: Array of found files

Parameters:

mixed   $args   —  Either array or string with the command line

[ Top ]

mkDir   [line 218]

bool mkDir( string $args)

Make directories. Note that we use call_user_func('mkdir') to avoid a problem with ZE2 calling System::mkDir instead of the native PHP func.
  • Return: True for success
  • Access: public

Parameters:

string   $args   —  the name of the director(y|ies) to create

[ Top ]

mktemp   [line 348]

mixed mktemp( [string $args = null])

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.

  • Return: the full path of the created (file|dir) or false
  • See: System::tmpdir()
  • Access: public

Parameters:

string   $args   —  The arguments

[ Top ]

rm   [line 175]

mixed rm( string $args)

The rm command for removing files.

Supports multiple files and dirs and also recursive deletes

  • Return: PEAR_Error or true for success
  • Access: public

Parameters:

string   $args   —  the arguments for rm

[ Top ]

tmpdir   [line 407]

string tmpdir( )

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

  • Return: The temporal directory on the system

[ Top ]

which   [line 434]

mixed which( string $program, [ $fallback = false])

The "which" command (show the full path of a command)
  • Return: A string with the full path or false if not found
  • Author: Stig Bakken <ssb@php.net>

Parameters:

string   $program   —  The command to search for
   $fallback   — 

[ Top ]


Documentation generated on Mon, 11 Mar 2019 14:24:01 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.