Exemple #1
0
 /**
  * Moves a file
  *
  * @param   string $src   The path to the source file
  * @param   string $dest  The path to the destination file
  * @param   bool   $force Force move it.
  *
  * @throws Exception\FilesystemException
  * @return  boolean  True on success
  *
  * @since   2.0
  */
 public static function move($src, $dest, $force = false)
 {
     // Check src path
     if (!is_readable($src)) {
         return 'Cannot find source file.';
     }
     // Delete first if exists
     if (file_exists($dest)) {
         if ($force) {
             Filesystem::delete($dest);
         } else {
             throw new FilesystemException('File: ' . $dest . ' exists, move failed.');
         }
     }
     // Check folder exists
     $dir = dirname($dest);
     if (!is_dir($dir)) {
         Folder::create($dir);
     }
     if (!@rename($src, $dest)) {
         throw new FilesystemException(__METHOD__ . ': Rename failed.');
     }
     return true;
 }
 /**
  * Destructor
  */
 public function __destruct()
 {
     Filesystem::delete(__DIR__ . '/cache');
 }
Exemple #3
0
 /**
  * Method to test delete().
  *
  * @return void
  *
  * @covers Windwalker\Filesystem\Filesystem::delete
  */
 public function testDelete()
 {
     Filesystem::delete(static::$dest);
     $this->assertFalse(is_dir(static::$dest));
     $this->assertFileNotExists(static::$dest . '/folder1/level2/file3');
 }
Exemple #4
0
if (is_file(__DIR__ . '/vendor/autoload.php')) {
    require_once __DIR__ . '/vendor/autoload.php';
}
use Windwalker\Filesystem\File;
use Windwalker\Filesystem\Path;
use Windwalker\Filesystem\Folder;
use Windwalker\Filesystem\Filesystem;
use Alchemy\Zippy\Zippy;
Task::register('build', function ($task) {
    $basepath = realpath(__DIR__ . '/..');
    $distfolder = Path::clean($basepath . '/dist');
    $pluginfolder = Path::clean($distfolder . '/notify');
    $task->writeln('Cleaning files out.');
    // Prepare dist folder
    if (file_exists($distfolder)) {
        Filesystem::delete($distfolder);
        Folder::create($distfolder);
    }
    $task->writeln('Copying files over.');
    recursiveCopy('dev', $basepath, $distfolder);
    $task->writeln('Running composer');
    $task->exec(function ($process) {
        $basepath = realpath(__DIR__ . '/..');
        $distfolder = Path::clean($basepath . '/dist');
        $distfolder = str_replace(' ', '\\ ', $distfolder);
        $process->runLocally("cd " . $distfolder . '/dev' . " && composer install --prefer-dist --optimize-autoloader");
        $process->runLocally("cd .. && cd ..");
    });
    Folder::move($distfolder . '/dev', $distfolder . '/notify');
    $task->writeln('Zipping');
    $zippy = Zippy::load();