Skip to content

Filesystem ​

final class · pocketmine\utils\Filesystem · source

Constants ​

CLEAN_PATH_PLUGINS_PREFIX ​

php
public const CLEAN_PATH_PLUGINS_PREFIX = "plugins"

CLEAN_PATH_SRC_PREFIX ​

php
public const CLEAN_PATH_SRC_PREFIX = "pmsrc"

Methods ​

addCleanedPath() ​

php
public static function addCleanedPath(string $path, string $replacement) : void

cleanPath() ​

php
public static function cleanPath(string $path) : string

createLockFile() ​

php
public static function createLockFile(string $lockFilePath) : ?int

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.

fileGetContents() ​

php
public static function fileGetContents(string $fileName, bool $useIncludePath = false, $context = null, int $offset = 0, ?int $length = null) : string

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

getCleanedPaths() ​

php
public static function getCleanedPaths() : array

recursiveCopy() ​

php
public static function recursiveCopy(string $origin, string $destination) : void

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

php
public static function recursiveUnlink(string $dir) : void

releaseLockFile() ​

php
public static function releaseLockFile(string $lockFilePath) : void

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

safeFilePutContents() ​

php
public static function safeFilePutContents(string $fileName, string $contents, int $flags = 0, $context = null) : void

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.

VanillaMine is a fork of PocketMine-MP, maintained by Luxury Nodes. Not affiliated with the PMMP team or Mojang.