<?php
namespace ModulesAbstract\FluxRest\ResponseHandler\Operation; class MoveFile extends OperationAbstract { public $path = ""; public $newpath = ""; public function handle() { $basePath = $this->FluXEmulator->getBasePath(); if (!$basePath) { throw new \Exception\IO\Base(sprintf("basePath wasn't defined!")); } if (!$this->newpath) { throw new \Exception\IO\Base(sprintf("newpath wasn't defined!")); } $newFile = new \SplFileInfo($this->FluXEmulator->getRestrictedBasePath() . $this->newpath); if (!\Engine\Dir::check($newFile->getPath())) { \Engine\Dir::create($newFile->getPath()); } if (!rename($basePath . $this->path, $newFile->getPathname())) { throw new \Exception\IO\Base(sprintf("Cannot move '%s' to '%s'", $basePath . $this->path, $this->newpath)); } } } 