PocketMine-MP 5.15.1 git-fb9a74e8799c71ed8292cfa53abe7a4c9204629d
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_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 

Definition at line 150 of file Filesystem.php.

◆ cleanPath()

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

Definition at line 163 of file Filesystem.php.

◆ createLockFile()

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

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.

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

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 

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



Definition at line 305 of file Filesystem.php.

Referenced by pocketmine\resourcepacks\ResourcePackManager\__construct(), pocketmine\data\bedrock\block\upgrade\BlockStateUpgradeSchemaUtils\loadSchemas(), and pocketmine\data\bedrock\item\upgrade\ItemIdMetaUpgradeSchemaUtils\loadSchemas().

+ Here is the caller graph for this function:

◆ getCleanedPaths()

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

Definition at line 161 of file Filesystem.php.

◆ recursiveCopy()

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

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)

Definition at line 81 of file Filesystem.php.

◆ releaseLockFile()

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

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


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 

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.

resource | null$contextContext to pass to file_put_contents

RuntimeException if the operation failed for any reason

Definition at line 238 of file Filesystem.php.

Member Data Documentation


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

Definition at line 75 of file Filesystem.php.


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: