Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Deleting && Copying files

Comments in 'Plugin Development' started by Kvetinac97, Jul 9, 2015.

  1. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    Hi. How can I delete whole world (way is /worlds/myworld)/config file of plugin (plugin is named WorldManager, so way is /plugins/WorldManager/config.yml) or copy(/plugins/WorldManager/backup.yml)/ (/worlds/myworld_backup) to same folder with name (config.yml)/( myworld)? It's good for some minigames plugins.
  2. TonyDroide
    Offline

    TonyDroide Active Member Plugin Developer

    Joined:
    Jun 5, 2015
    Posts:
    122
    Plugins:
    1
    Minecraft User:
    TonyDroidd
    You confused me lol
    Andrey Nazarchuk likes this.
  3. ahoj_truhliku
    Offline

    ahoj_truhliku Banned

    Joined:
    Jul 9, 2015
    Posts:
    89
    Minecraft User:
    Creeperface001
    http://php.net/manual/en/ref.filesystem.php

    není zač :)
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    https://github.com/PEMapModder/Legi.../src/legionpe/theta/utils/MUtils.php#L103-131
    Also, if you found these functions too unstable or don't want to use them, you can use system dependent functions (highly discouraged for public plugins).
    For Mac and Linux:
    PHP:
    exec("rm -r " $Server->getDataPath() . "worlds/" $world_name );
    For Widnows:
    PHP:
    exec("del " $Server->getDataPath() . "worlds/" $world_name );
    But be warned that this is bad practice, so...

    [​IMG]
  5. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,747
    Minecraft User:
    Legoboy0215
    Moral of the story: When writing code, lock your room door and do not invite @PEMapModder with his pet dinosaur.
    CrazedMiner and PEMapModder like this.
  6. iiDeathStrokeii
    Offline

    iiDeathStrokeii Active Member

    Joined:
    Mar 30, 2015
    Posts:
    111
    Minecraft User:
    iiDeathstrokeii
    Can you not use unlink() ?
  7. iJoshuaHD
    Offline

    iJoshuaHD Notable Member Plugin Developer

    Joined:
    Nov 7, 2013
    Posts:
    1,201
    Plugins:
    4
    Minecraft User:
    iJoshuaHD
    Method I use from my SG plugin:
    PHP:
    public function delete_dir($folder) {
      
    $glob glob($folder);
        foreach(
    $glob as $g){
        if(!
    is_dir($g)){
          @
    unlink($g);
        }else{
          
    $this->delete_dir("$g/*");
          @
    rmdir($g);
        }
      }
    }
    public function 
    recurse_copy($src$dst) {
      
    $dir opendir($src);
      @
    mkdir($dst);
      while(
    false !== ($file readdir($dir))){
        if((
    $file != '.') && ($file != '..')){
          if(
    is_dir($src '/' $file)){
            
    $this->recurse_copy($src '/' $file,$dst '/' $file);
          }else{
            
    copy($src '/' $file,$dst '/' $file);
          }
        }
      }
    closedir($dir);
    }
    CrazedMiner and iiDeathStrokeii like this.

Share This Page

Advertisement