BlueSpice MediaWiki master
 All Classes Namespaces Files Functions Variables Groups Pages
FSFile Class Reference
Inheritance diagram for FSFile:

Public Member Functions

 __construct ($path)
 
 getPath ()
 
 exists ()
 
 getSize ()
 
 getTimestamp ()
 
 getProps ($ext=true)
 
 getSha1Base36 ($recache=false)
 

Static Public Member Functions

static placeholderProps ()
 
static extensionFromPath ($path)
 
static getPropsFromPath ($path, $ext=true)
 
static getSha1Base36FromPath ($path)
 

Protected Attributes

 $path
 
 $sha1Base36
 

Detailed Description

Class representing a non-directory file on the file system

Constructor & Destructor Documentation

FSFile::__construct (   $path)

Sets up the file object

Parameters
string$pathPath to temporary file on local disk

Member Function Documentation

FSFile::exists ( )

Checks if the file exists

Returns
bool
static FSFile::extensionFromPath (   $path)
static

Get the final file extension from a file system path

Parameters
string$path
Returns
string
FSFile::getPath ( )

Returns the file system path

Returns
string
FSFile::getProps (   $ext = true)

Get an associative array containing information about a file with the given storage path.

Resulting array fields include:

  • fileExists
  • size (filesize in bytes)
  • mime (as major/minor)
  • file-mime (as major/minor)
  • sha1 (in base 36)
  • major_mime
  • minor_mime
Parameters
string | bool$extThe file extension, or true to extract it from the filename. Set it to false to ignore the extension. Currently unused.
Returns
array
static FSFile::getPropsFromPath (   $path,
  $ext = true 
)
static

Get an associative array containing information about a file in the local filesystem.

Parameters
string$pathAbsolute local filesystem path
string | bool$extThe file extension, or true to extract it from the filename. Set it to false to ignore the extension.
Returns
array
FSFile::getSha1Base36 (   $recache = false)

Get a SHA-1 hash of a file in the local filesystem, in base-36 lower case encoding, zero padded to 31 digits.

160 log 2 / log 36 = 30.95, so the 160-bit hash fills 31 digits in base 36 fairly neatly.

Parameters
bool$recache
Returns
bool|string False on failure
static FSFile::getSha1Base36FromPath (   $path)
static

Get a SHA-1 hash of a file in the local filesystem, in base-36 lower case encoding, zero padded to 31 digits.

160 log 2 / log 36 = 30.95, so the 160-bit hash fills 31 digits in base 36 fairly neatly.

Parameters
string$path
Returns
bool|string False on failure
FSFile::getSize ( )

Get the file size in bytes

Returns
int|bool
FSFile::getTimestamp ( )

Get the file's last-modified timestamp

Returns
string|bool TS_MW timestamp or false on failure
static FSFile::placeholderProps ( )
static

Placeholder file properties to use for files that don't exist

Resulting array fields include:

  • fileExists
  • size (filesize in bytes)
  • mime (as major/minor)
  • file-mime (as major/minor)
  • sha1 (in base 36)
  • major_mime
  • minor_mime
Returns
array

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