nyroFwk  0.2
Static Public Member Functions | Private Member Functions | Static Private Member Functions | Static Private Attributes
file Class Reference

Static Public Member Functions

static init ()
 
static saveCache ()
 
static exists ($file)
 
static name ($file)
 
static nyroExists ($prm)
 
static webExists ($file)
 
static read ($file)
 
static write ($file, $content)
 
static copy ($oldName, $newName)
 
static move ($oldName, $newName)
 
static createDir ($path, $chmod=0777)
 
static date ($file)
 
static isLater ($file1, $file2)
 
static size ($file)
 
static humanSize ($file, $sizeGiven=false)
 
static delete ($file)
 
static multipleDelete ($pattern, $matchPattern=null)
 
static getExt ($file)
 
static getType ($file)
 
static fetch ($file, array $vars=array())
 
static search ($pattern, $matchPattern=null)
 

Private Member Functions

 __construct ()
 

Static Private Member Functions

static initCfg ()
 
static initCache ()
 

Static Private Attributes

static $cfg
 
static $searchFiles = array()
 
static $saveCacheFiles = false
 
static $cacheFiles = null
 

Detailed Description

To read and write files Same use like globals variables Singleton

Definition at line 12 of file file.class.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( )
private

No instanciation for this class

Definition at line 46 of file file.class.php.

Member Function Documentation

◆ copy()

static copy (   $oldName,
  $newName 
)
static

Copy a file to a new location

Parameters
string$oldNameOld name path
string$newNameNew name path
Returns
bool True if success

Definition at line 268 of file file.class.php.

◆ createDir()

static createDir (   $path,
  $chmod = 0777 
)
static

Create a directory, and all subdirectory if needed If directory already exists, nothing is done

Parameters
string$path
string$chmod
Returns
bool True if directory exists

Definition at line 291 of file file.class.php.

◆ date()

static date (   $file)
static

Get the file update date

Parameters
string$fileThe file path
Returns
int Timestamp

Definition at line 302 of file file.class.php.

◆ delete()

static delete (   $file)
static

Delete a file

Parameters
string$fileThe file path
Returns
bool True if success

Definition at line 355 of file file.class.php.

◆ exists()

static exists (   $file)
static

Check if a file exists

Parameters
string$fileFile path
Returns
bool

Definition at line 97 of file file.class.php.

◆ fetch()

static fetch (   $file,
array  $vars = array() 
)
static

Fetch a file with vars (used in tpl)

Parameters
string$fileFile path name
array$varsVariables used in the php file
Returns
string The file fetched

Definition at line 441 of file file.class.php.

◆ getExt()

static getExt (   $file)
static

Get the file extension

Parameters
string$fileThe filename
Returns
null|string The extension

Definition at line 400 of file file.class.php.

◆ getType()

static getType (   $file)
static

Get the Mime Type of a file

Parameters
string$fileFile path name
Returns
string

Definition at line 413 of file file.class.php.

◆ humanSize()

static humanSize (   $file,
  $sizeGiven = false 
)
static

Get a human file size

Parameters
string$fileThe file path
boolean$sizeGivenIndicates if the size is given in firt param
Returns
string The human size

Definition at line 339 of file file.class.php.

◆ init()

static init ( )
static

Init the file elements

Definition at line 51 of file file.class.php.

◆ initCache()

static initCache ( )
staticprivate

Initialize the cache object

Definition at line 66 of file file.class.php.

◆ initCfg()

static initCfg ( )
staticprivate

Init the file configuration

Definition at line 58 of file file.class.php.

◆ isLater()

static isLater (   $file1,
  $file2 
)
static

Compare 2 date files

Parameters
string$file1The first file path
string$file2The second file path
Returns
bool True if the first file is later than the second

Definition at line 314 of file file.class.php.

◆ move()

static move (   $oldName,
  $newName 
)
static

Move a file to a new location

Parameters
string$oldNameOld name path
string$newNameNew name path
Returns
bool True if success

Definition at line 279 of file file.class.php.

◆ multipleDelete()

static multipleDelete (   $pattern,
  $matchPattern = null 
)
static

Delete files with a pattern

Parameters
string$patternThe pattern to delete files (glob used)
string$matchPatternA more specific pattern to be applied with preg_match
Returns
int Number of files deleted

Definition at line 386 of file file.class.php.

◆ name()

static name (   $file)
static

Get the filename from a path

Parameters
string$file
Returns
string

Definition at line 118 of file file.class.php.

◆ nyroExists()

static nyroExists (   $prm)
static

Try to find the file location, in the nyro installation in this order: my directory, plugin directory and nyro directory. The order can be reverse by setting rtl parameter to false. If the file is located on a subdirectory, use _ to replace /.

Parameters
array$prmPossible values :
  • name (required) string: FileName (with _ to replace /)
  • realName boolean: Indicate if the given name is real or should be parsed
  • type string: class, extend, cfg, tpl, lib or other (default: class)
  • rtl bool: see description (default: true)
  • list bool: Search all the matched files and return the order list. (default: false)
  • tplExt string: Tpl Extension (default: request::get('out'))
Returns
false|string|array The absolute file location, an absolute file location array or false if not found

Definition at line 137 of file file.class.php.

◆ read()

static read (   $file)
static

Read a file

Parameters
string$fileThe file path
Returns
string|false The file content

Definition at line 242 of file file.class.php.

◆ saveCache()

static saveCache ( )
static

Save the cache

Definition at line 84 of file file.class.php.

◆ search()

static search (   $pattern,
  $matchPattern = null 
)
static

Search files regarding a pattern

Parameters
string$pattern
string$matchPatternA more specific pattern to be applied with preg_match
Returns
array

Definition at line 457 of file file.class.php.

◆ size()

static size (   $file)
static

Get a file size

Parameters
string$fileThe file path
Returns
int The file size

Definition at line 325 of file file.class.php.

◆ webExists()

static webExists (   $file)
static

Check if a file exists in the web directory

Parameters
string$fileFilename
Returns
bool

Definition at line 232 of file file.class.php.

◆ write()

static write (   $file,
  $content 
)
static

Write into a file

Parameters
string$fileThe file path
string$contentThe file content
Returns
bool True if success

Definition at line 256 of file file.class.php.

Field Documentation

◆ $cacheFiles

$cacheFiles = null
staticprivate

Definition at line 41 of file file.class.php.

◆ $cfg

$cfg
staticprivate

Definition at line 19 of file file.class.php.

◆ $saveCacheFiles

$saveCacheFiles = false
staticprivate

Definition at line 34 of file file.class.php.

◆ $searchFiles

$searchFiles = array()
staticprivate

Checkif a file exists

Parameters
string$fileThe file path
Returns
bool

Definition at line 27 of file file.class.php.


The documentation for this class was generated from the following file:
Generated on Sun Oct 15 2017 22:25:20 for nyroFwk by doxygen 1.8.13