MediaWiki  REL1_22
FSFile Class Reference

Class representing a non-directory file on the file system. More...

Inheritance diagram for FSFile:

List of all members.

Public Member Functions

 __construct ($path)
 Sets up the file object.
 exists ()
 Checks if the file exists.
 getMimeType ()
 Guess the MIME type from the file contents alone.
 getPath ()
 Returns the file system path.
 getProps ($ext=true)
 Get an associative array containing information about a file with the given storage path.
 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.
 getSize ()
 Get the file size in bytes.
 getTimestamp ()
 Get the file's last-modified timestamp.

Static Public Member Functions

static extensionFromPath ($path)
 Get the final file extension from a file system path.
static getPropsFromPath ($path, $ext=true)
 Get an associative array containing information about a file in the local filesystem.
static getSha1Base36FromPath ($path)
 Get a SHA-1 hash of a file in the local filesystem, in base-36 lower case encoding, zero padded to 31 digits.
static placeholderProps ()
 Placeholder file properties to use for files that don't exist.

Protected Member Functions

 extractImageSizeInfo (array $gis)
 Exract image size information.

Protected Attributes

 $path
 $sha1Base36

Detailed Description

Class representing a non-directory file on the file system.

Definition at line 29 of file FSFile.php.


Constructor & Destructor Documentation

FSFile::__construct ( path)

Sets up the file object.

Parameters:
string$pathPath to temporary file on local disk
Exceptions:
MWException

Definition at line 39 of file FSFile.php.

References $path, and FileBackend\isStoragePath().


Member Function Documentation

Checks if the file exists.

Returns:
bool

Reimplemented in MockFSFile.

Definition at line 60 of file FSFile.php.

Referenced by getProps().

static FSFile::extensionFromPath ( path) [static]

Get the final file extension from a file system path.

Parameters:
string$path
Returns:
string

Definition at line 226 of file FSFile.php.

References $path.

Referenced by getProps().

FSFile::extractImageSizeInfo ( array gis) [protected]

Exract image size information.

Parameters:
array$gis
Returns:
Array

Definition at line 177 of file FSFile.php.

References array().

Referenced by getProps().

Guess the MIME type from the file contents alone.

Returns:
string

Reimplemented in MockFSFile.

Definition at line 93 of file FSFile.php.

References MimeMagic\singleton().

Referenced by getProps().

Returns the file system path.

Returns:
String

Definition at line 51 of file FSFile.php.

FSFile::getProps ( ext = true)

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

Parameters:
Mixed$ext,:the file extension, or true to extract it from the filename. Set it to false to ignore the extension.
Returns:
array

Reimplemented in MockFSFile.

Definition at line 106 of file FSFile.php.

References $ext, array(), exists(), extensionFromPath(), extractImageSizeInfo(), MediaHandler\getHandler(), getMimeType(), getSha1Base36(), getSize(), list, object, placeholderProps(), MimeMagic\singleton(), File\splitMime(), wfDebug(), wfProfileIn(), and wfProfileOut().

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
Mixed$ext,:the file extension, or true to extract it from the filename. Set it to false to ignore the extension.
Returns:
array

Definition at line 239 of file FSFile.php.

References $ext, and $path.

Referenced by UploadBase\verifyFile(), and UploadBase\verifyPartialFile().

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

Reimplemented in MockFSFile.

Definition at line 200 of file FSFile.php.

References wfBaseConvert(), wfProfileIn(), wfProfileOut(), wfRestoreWarnings(), and wfSuppressWarnings().

Referenced by getProps().

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

Definition at line 254 of file FSFile.php.

References $path.

Referenced by ApiTestCaseUpload\deleteFileByContent(), and UploadBase\getTempFileSha1Base36().

Get the file size in bytes.

Returns:
int|bool

Reimplemented in MockFSFile.

Definition at line 69 of file FSFile.php.

Referenced by getProps().

Get the file's last-modified timestamp.

Returns:
string|bool TS_MW timestamp or false on failure

Reimplemented in MockFSFile.

Definition at line 78 of file FSFile.php.

References $timestamp, wfRestoreWarnings(), wfSuppressWarnings(), and wfTimestamp().

static FSFile::placeholderProps ( ) [static]

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

Returns:
Array

Definition at line 158 of file FSFile.php.

References array().

Referenced by getProps().


Member Data Documentation

FSFile::$path [protected]
FSFile::$sha1Base36 [protected]

Reimplemented in MockFSFile.

Definition at line 31 of file FSFile.php.


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