Removed all @mkdir() calls

This commit is contained in:
Shoghi Cervantes 2015-01-02 18:52:45 +01:00
parent 692045d714
commit f46473bbe8
No known key found for this signature in database
GPG Key ID: 78464DB0A7837F89
7 changed files with 40 additions and 12 deletions

View File

@ -127,7 +127,9 @@ namespace pocketmine {
define("pocketmine\\ANSI", (Utils::getOS() !== "win" or isset($opts["enable-ansi"])) and !isset($opts["disable-ansi"]));
@mkdir(\pocketmine\DATA, 0777, true);
if(!file_exists(\pocketmine\DATA)){
mkdir(\pocketmine\DATA, 0777, true);
}
//Logger has a dependency on timezone, so we'll set it to UTC until we can get the actual timezone.
date_default_timezone_set("UTC");

View File

@ -1458,9 +1458,17 @@ class Server{
$this->autoloader = $autoloader;
$this->logger = $logger;
$this->filePath = $filePath;
@mkdir($dataPath . "worlds/", 0777);
@mkdir($dataPath . "players/", 0777);
@mkdir($pluginPath, 0777);
if(!file_exists($dataPath . "worlds/")){
mkdir($dataPath . "worlds/", 0777);
}
if(!file_exists($dataPath . "players/")){
mkdir($dataPath . "players/", 0777);
}
if(!file_exists($pluginPath)){
mkdir($pluginPath, 0777);
}
$this->dataPath = realpath($dataPath) . DIRECTORY_SEPARATOR;
$this->pluginPath = realpath($pluginPath) . DIRECTORY_SEPARATOR;

View File

@ -78,7 +78,10 @@ class TimingsCommand extends VanillaCommand{
$sampleTime = microtime(true) - self::$timingStart;
$index = 0;
$timingFolder = $sender->getServer()->getDataPath() . "timings/";
@mkdir($timingFolder, 0777);
if(!file_exists($timingFolder)){
mkdir($timingFolder, 0777);
}
$timings = $timingFolder . "timings.txt";
while(file_exists($timings)){
$timings = $timingFolder . "timings" . (++$index) . ".txt";

View File

@ -42,7 +42,9 @@ abstract class BaseLevelProvider implements LevelProvider{
public function __construct(Level $level, $path){
$this->level = $level;
$this->path = $path;
@mkdir($this->path, 0777, true);
if(!file_exists($this->path)){
mkdir($this->path, 0777, true);
}
$nbt = new NBT(NBT::BIG_ENDIAN);
$nbt->readCompressed(file_get_contents($this->getPath() . "level.dat"));
$levelData = $nbt->getData();

View File

@ -47,7 +47,9 @@ class LevelDB extends BaseLevelProvider{
public function __construct(Level $level, $path){
$this->level = $level;
$this->path = $path;
@mkdir($this->path, 0777, true);
if(!file_exists($this->path)){
mkdir($this->path, 0777, true);
}
$nbt = new NBT(NBT::LITTLE_ENDIAN);
$nbt->read(substr(file_get_contents($this->getPath() . "level.dat"), 8));
$levelData = $nbt->getData();
@ -87,8 +89,12 @@ class LevelDB extends BaseLevelProvider{
}
public static function generate($path, $name, $seed, $generator, array $options = []){
@mkdir($path, 0777, true);
@mkdir($path . "/db", 0777);
if(!file_exists($path)){
mkdir($path, 0777, true);
}
if(!file_exists($path . "/db")){
mkdir($path . "/db", 0777, true);
}
//TODO, add extra details
$levelData = new Compound(null, [
"hardcore" => new Byte("hardcore", 0),

View File

@ -72,8 +72,13 @@ class McRegion extends BaseLevelProvider{
}
public static function generate($path, $name, $seed, $generator, array $options = []){
@mkdir($path, 0777, true);
@mkdir($path . "/region", 0777);
if(!file_exists($path)){
mkdir($path, 0777, true);
}
if(!file_exists($path . "/region")){
mkdir($path . "/region", 0777);
}
//TODO, add extra details
$levelData = new Compound("Data", [
"hardcore" => new Byte("hardcore", 0),

View File

@ -202,7 +202,9 @@ abstract class PluginBase implements Plugin{
$out = $this->dataFolder . $filename;
if(!file_exists($this->dataFolder)){
@mkdir($this->dataFolder, 0755, true);
if(!file_exists($this->dataFolder)){
mkdir($this->dataFolder, 0755, true);
}
}
if(file_exists($out) and $replace !== true){