mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-12 08:49:42 +00:00
Merge commit '786f416f2ef31726b9e6fa0a5edde36aecddf085'
# Conflicts: # resources/vanilla # src/plugin/PluginBase.php # src/utils/Utils.php
This commit is contained in:
commit
5b7a55660f
@ -53,7 +53,7 @@ class DiskResourceProvider implements ResourceProvider{
|
||||
* @return null|resource Resource data, or null
|
||||
*/
|
||||
public function getResource(string $filename){
|
||||
$filename = rtrim(str_replace("\\", "/", $filename), "/");
|
||||
$filename = rtrim(str_replace(DIRECTORY_SEPARATOR, "/", $filename), "/");
|
||||
if(file_exists($this->file . $filename)){
|
||||
$resource = fopen($this->file . $filename, "rb");
|
||||
if($resource === false) throw new AssumptionFailedError("fopen() should not fail on a file which exists");
|
||||
|
@ -83,9 +83,9 @@ abstract class PluginBase implements Plugin, CommandExecutor{
|
||||
$this->loader = $loader;
|
||||
$this->server = $server;
|
||||
$this->description = $description;
|
||||
$this->dataFolder = rtrim($dataFolder, "\\/") . "/";
|
||||
$this->dataFolder = rtrim($dataFolder, "/" . DIRECTORY_SEPARATOR) . "/";
|
||||
//TODO: this is accessed externally via reflection, not unused
|
||||
$this->file = rtrim($file, "\\/") . "/";
|
||||
$this->file = rtrim($file, "/" . DIRECTORY_SEPARATOR) . "/";
|
||||
$this->configFile = $this->dataFolder . "config.yml";
|
||||
|
||||
$prefix = $this->getDescription()->getPrefix();
|
||||
|
@ -42,6 +42,7 @@ use function str_replace;
|
||||
use function stream_get_contents;
|
||||
use function strpos;
|
||||
use function unlink;
|
||||
use const DIRECTORY_SEPARATOR;
|
||||
use const LOCK_EX;
|
||||
use const LOCK_NB;
|
||||
use const LOCK_SH;
|
||||
@ -80,7 +81,7 @@ final class Filesystem{
|
||||
* @return string
|
||||
*/
|
||||
public static function cleanPath($path){
|
||||
$result = str_replace(["\\", ".php", "phar://"], ["/", "", ""], $path);
|
||||
$result = str_replace([DIRECTORY_SEPARATOR, ".php", "phar://"], ["/", "", ""], $path);
|
||||
|
||||
//remove relative paths
|
||||
//TODO: make these paths dynamic so they can be unit-tested against
|
||||
@ -89,7 +90,7 @@ final class Filesystem{
|
||||
\pocketmine\PATH => ""
|
||||
];
|
||||
foreach($cleanPaths as $cleanPath => $replacement){
|
||||
$cleanPath = rtrim(str_replace(["\\", "phar://"], ["/", ""], $cleanPath), "/");
|
||||
$cleanPath = rtrim(str_replace([DIRECTORY_SEPARATOR, "phar://"], ["/", ""], $cleanPath), "/");
|
||||
if(strpos($result, $cleanPath) === 0){
|
||||
$result = ltrim(str_replace($cleanPath, $replacement, $result), "/");
|
||||
}
|
||||
|
@ -72,6 +72,7 @@ use function substr;
|
||||
use function sys_get_temp_dir;
|
||||
use function trim;
|
||||
use function xdebug_get_function_stack;
|
||||
use const DIRECTORY_SEPARATOR;
|
||||
use const PHP_EOL;
|
||||
use const PHP_INT_MAX;
|
||||
use const PHP_INT_SIZE;
|
||||
|
Loading…
x
Reference in New Issue
Block a user