use Cubist\Util\CommandLine;
use Cubist\Util\Text;
-abstract class Driver {
-
- /**
- * @var IServer
- */
- protected $_server;
-
- public function __construct(IServer $server) {
-
- $this->setServer($server);
- }
-
- /**
- * @return IServer
- */
- public function getServer() {
- return $this->_server;
- }
-
- /**
- * @param IServer $server
- */
- public function setServer($server) {
- $this->_server = $server;
- }
-
- public static function cleanInstallDir($path) {
- $path = str_replace('/\.{2,}/', '', $path);
- $path = preg_replace('/\/{2,}/', '/', $path);
- $path = trim($path, '/');
- return Text::str2URL($path, '-', true);
- }
-
- protected function _destPath($path) {
- return self::cleanInstallDir($path);
- }
-
- /**
- * @param $source string
- * @param $dest string
- * @param $mirror bool
- * @param $dryrun bool
- * @return CommandLine
- */
- abstract public function copy($source, $dest, $mirror = false, $dryrun = false);
+abstract class Driver
+{
+
+ /**
+ * @var IServer
+ */
+ protected $_server;
+
+ public function __construct(IServer $server)
+ {
+
+ $this->setServer($server);
+ }
+
+ /**
+ * @return IServer
+ */
+ public function getServer()
+ {
+ return $this->_server;
+ }
+
+ /**
+ * @param IServer $server
+ */
+ public function setServer($server)
+ {
+ $this->_server = $server;
+ }
+
+ public static function cleanInstallDir($path)
+ {
+ $path = str_replace('/\.{2,}/', '', $path);
+ $path = preg_replace('/\/{2,}/', '/', $path);
+ $path = trim($path, '/');
+ return Text::str2URL($path, '-', true);
+ }
+
+ protected function _destPath($path)
+ {
+ return self::cleanInstallDir($path);
+ }
+
+ /**
+ * @param $source string
+ * @param $dest string
+ * @param $mirror bool
+ * @param $dryrun bool
+ * @return CommandLine
+ */
+ abstract public function copy($source, $dest, $mirror = false, $dryrun = false);
+
+ abstract public function copyFile($source, $dest);
}
\ No newline at end of file
use Cubist\Util\CommandLine\Rsync;
-class Local extends Driver {
- protected $_rootPath = '';
-
- public function __construct(IServer $server, $rootPath = null) {
- parent::__construct($server);
- if (null !== $rootPath) {
- $this->setRootPath($rootPath);
- }
- }
-
- /**
- * @param string $rootPath
- */
- public function setRootPath($rootPath) {
- $this->_rootPath = $rootPath;
- }
-
- /**
- * @return string
- */
- public function getRootPath() {
- return $this->_rootPath;
- }
-
- /**
- * @param $path
- * @return string
- */
- protected function _destPath($path) {
- return rtrim($this->getRootPath(), '/') . '/' . self::cleanInstallDir($path) . '/';
- }
-
- public function copy($source, $dest, $mirror = false, $dryrun = false) {
- $rsync = new Rsync($source, $dest);
- $rsync->setServer($this->getServer());
- $rsync->setBasePath(rtrim($this->getRootPath(), '/') . '/' . ltrim($this->getServer()->getBasePath(), '/'));
- $rsync->setMirror($mirror);
- $rsync->setDryRun($dryrun);
- $rsync->execute();
- return $rsync;
- }
+class Local extends Driver
+{
+ protected $_rootPath = '';
+
+ public function __construct(IServer $server, $rootPath = null)
+ {
+ parent::__construct($server);
+ if (null !== $rootPath) {
+ $this->setRootPath($rootPath);
+ }
+ }
+
+ /**
+ * @param string $rootPath
+ */
+ public function setRootPath($rootPath)
+ {
+ $this->_rootPath = $rootPath;
+ }
+
+ /**
+ * @return string
+ */
+ public function getRootPath()
+ {
+ return $this->_rootPath;
+ }
+
+ /**
+ * @param $path
+ * @return string
+ */
+ protected function _destPath($path)
+ {
+ return rtrim($this->getRootPath(), '/') . '/' . self::cleanInstallDir($path) . '/';
+ }
+
+ public function copy($source, $dest, $mirror = false, $dryrun = false)
+ {
+ $rsync = new Rsync($source, $dest);
+ $rsync->setServer($this->getServer());
+ $rsync->setBasePath($this->_basePath());
+ $rsync->setMirror($mirror);
+ $rsync->setDryRun($dryrun);
+ $rsync->execute();
+ return $rsync;
+ }
+
+ protected function _basePath()
+ {
+ return rtrim($this->getRootPath(), '/') . '/' . ltrim($this->getServer()->getBasePath(), '/');
+ }
+
+ public function copyFile($source, $dest)
+ {
+ return copy($source, $this->_basePath() . '/' . $dest);
+ }
}
\ No newline at end of file