PocketMine-MP 5.23.3 git-f7687af337d001ddbcc47b8e773f014a33faa662
Loading...
Searching...
No Matches
pocketmine\utils\Filesystem Class Reference
+ Collaboration diagram for pocketmine\utils\Filesystem:

Static Public Member Functions

static addCleanedPath (string $path, string $replacement)
 
static cleanPath (string $path)
 
static createLockFile (string $lockFilePath)
 
static fileGetContents (string $fileName, bool $useIncludePath=false, $context=null, int $offset=0, ?int $length=null)
 
static getCleanedPaths ()
 
static recursiveCopy (string $origin, string $destination)
 
static recursiveUnlink (string $dir)
 
static releaseLockFile (string $lockFilePath)
 
static safeFilePutContents (string $fileName, string $contents, int $flags=0, $context=null)
 

Public Attributes

const CLEAN_PATH_PLUGINS_PREFIX = "plugins"
 
const CLEAN_PATH_SRC_PREFIX = "pmsrc"
 

Detailed Description

Definition at line 63 of file Filesystem.php.

Member Function Documentation

◆ addCleanedPath()

static pocketmine\utils\Filesystem::addCleanedPath ( string $path,
string $replacement )
static

Definition at line 150 of file Filesystem.php.

◆ cleanPath()

static pocketmine\utils\Filesystem::cleanPath ( string $path)
static

Definition at line 163 of file Filesystem.php.

◆ createLockFile()

static pocketmine\utils\Filesystem::createLockFile ( string $lockFilePath)
static

Attempts to get a lock on the specified file, creating it if it does not exist. This is typically used for IPC to inform other processes that some file or folder is already in use, to avoid data corruption. If this function succeeds in gaining a lock on the file, it writes the current PID to the file.

Returns
int|null process ID of the process currently holding the lock failure, null on success.
Exceptions

InvalidArgumentException if the lock file path is invalid (e.g. parent directory doesn't exist, permission denied)

Definition at line 185 of file Filesystem.php.

◆ fileGetContents()

static pocketmine\utils\Filesystem::fileGetContents ( string $fileName,
bool $useIncludePath = false,
$context = null,
int $offset = 0,
?int $length = null )
static

Wrapper around file_get_contents() which throws an exception instead of generating E_* errors.

@phpstan-param resource|null $context @phpstan-param 0|positive-int $offset @phpstan-param 0|positive-int|null $length

Exceptions

RuntimeException

Definition at line 305 of file Filesystem.php.

◆ getCleanedPaths()

static pocketmine\utils\Filesystem::getCleanedPaths ( )
static
Returns
string[] @phpstan-return array<string, string>

Definition at line 161 of file Filesystem.php.

◆ recursiveCopy()

static pocketmine\utils\Filesystem::recursiveCopy ( string $origin,
string $destination )
static

Recursively copies a directory to a new location. The parent directories for the destination must exist.

Definition at line 103 of file Filesystem.php.

◆ recursiveUnlink()

static pocketmine\utils\Filesystem::recursiveUnlink ( string $dir)
static

Definition at line 81 of file Filesystem.php.

◆ releaseLockFile()

static pocketmine\utils\Filesystem::releaseLockFile ( string $lockFilePath)
static

Releases a file lock previously acquired by createLockFile() and deletes the lock file.

Exceptions

InvalidArgumentException if the lock file path is invalid (e.g. parent directory doesn't exist, permission denied)

Definition at line 214 of file Filesystem.php.

◆ safeFilePutContents()

static pocketmine\utils\Filesystem::safeFilePutContents ( string $fileName,
string $contents,
int $flags = 0,
$context = null )
static

Wrapper around file_put_contents() which writes to a temporary file before overwriting the original. If the disk is full, writing to the temporary file will fail before the original file is modified, leaving it untouched.

This is necessary because file_put_contents() destroys the data currently in the file if it fails to write the new contents.

Parameters
resource | null$contextContext to pass to file_put_contents
Exceptions

RuntimeException if the operation failed for any reason

Definition at line 238 of file Filesystem.php.

Member Data Documentation

◆ CLEAN_PATH_PLUGINS_PREFIX

const pocketmine\utils\Filesystem::CLEAN_PATH_PLUGINS_PREFIX = "plugins"

Definition at line 75 of file Filesystem.php.

◆ CLEAN_PATH_SRC_PREFIX

const pocketmine\utils\Filesystem::CLEAN_PATH_SRC_PREFIX = "pmsrc"

Definition at line 74 of file Filesystem.php.


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