MediaWiki REL1_39
TempFSFile Class Reference

This class is used to hold the location and do limited manipulation of files stored temporarily (this will be whatever wfTempDir() returns) More...

Inheritance diagram for TempFSFile:
Collaboration diagram for TempFSFile:

Public Member Functions

 __construct ( $path)
 Do not call directly.
 
 __destruct ()
 Cleans up after the temporary file by deleting it.
 
 autocollect ()
 Set flag clean up after the temporary file.
 
 bind ( $object)
 Clean up the temporary file only after an object goes out of scope.
 
 preserve ()
 Set flag to not clean up after the temporary file.
 
 purge ()
 Purge this file off the file system.
 
- Public Member Functions inherited from FSFile
 exists ()
 Checks if the file exists.
 
 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 factory ( $prefix, $extension='', $tmpDirectory=null)
 Make a new temporary file on the file system.
 
static getUsableTempDirectory ()
 
static purgeAllOnShutdown ()
 Try to make sure that all files are purged on error.
 
- Static Public Member Functions inherited from FSFile
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 Attributes

bool $canDelete = false
 Garbage collect the temp file.
 
- Protected Attributes inherited from FSFile
string $path
 Path to file.
 
string $sha1Base36
 File SHA-1 in base 36.
 

Static Protected Attributes

static array $pathsCollect = null
 Map of (path => 1) for paths to delete on shutdown.
 

Detailed Description

This class is used to hold the location and do limited manipulation of files stored temporarily (this will be whatever wfTempDir() returns)

Definition at line 35 of file TempFSFile.php.

Constructor & Destructor Documentation

◆ __construct()

TempFSFile::__construct ( $path)

Do not call directly.

Use TempFSFileFactory

Parameters
string$path

Reimplemented from FSFile.

Definition at line 55 of file TempFSFile.php.

References $path.

◆ __destruct()

TempFSFile::__destruct ( )

Cleans up after the temporary file by deleting it.

Definition at line 205 of file TempFSFile.php.

References purge().

Member Function Documentation

◆ autocollect()

TempFSFile::autocollect ( )

Set flag clean up after the temporary file.

Returns
TempFSFile This object

Definition at line 179 of file TempFSFile.php.

References $path.

◆ bind()

TempFSFile::bind ( $object)

Clean up the temporary file only after an object goes out of scope.

Parameters
mixed$object
Returns
TempFSFile This object

Definition at line 140 of file TempFSFile.php.

◆ factory()

static TempFSFile::factory ( $prefix,
$extension = '',
$tmpDirectory = null )
static

Make a new temporary file on the file system.

Temporary files may be purged when the file object falls out of scope.

Deprecated
since 1.34, use TempFSFileFactory directly
Parameters
string$prefix
string$extensionOptional file extension
string | null$tmpDirectoryOptional parent directory
Returns
TempFSFile|null

Definition at line 77 of file TempFSFile.php.

◆ getUsableTempDirectory()

static TempFSFile::getUsableTempDirectory ( )
static
Todo
Is there any useful way to test this? Would it be useful to make this non-static on TempFSFileFactory?
Returns
string Filesystem path to a temporary directory
Exceptions
RuntimeExceptionif no writable temporary directory can be found

Definition at line 88 of file TempFSFile.php.

Referenced by MediaWiki\FileBackend\FSFile\TempFSFileFactory\newTempFSFile().

◆ preserve()

TempFSFile::preserve ( )

Set flag to not clean up after the temporary file.

Returns
TempFSFile This object

Definition at line 166 of file TempFSFile.php.

◆ purge()

TempFSFile::purge ( )

Purge this file off the file system.

Returns
bool Success

Definition at line 123 of file TempFSFile.php.

Referenced by __destruct().

◆ purgeAllOnShutdown()

static TempFSFile::purgeAllOnShutdown ( )
static

Try to make sure that all files are purged on error.

This method should only be called internally

Definition at line 194 of file TempFSFile.php.

References $path.

Member Data Documentation

◆ $canDelete

bool TempFSFile::$canDelete = false
protected

Garbage collect the temp file.

Definition at line 37 of file TempFSFile.php.

◆ $pathsCollect

array TempFSFile::$pathsCollect = null
staticprotected

Map of (path => 1) for paths to delete on shutdown.

Definition at line 40 of file TempFSFile.php.


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