function __construct($directory = null)
 {
     if (!$directory || !is_dir($directory)) {
         $this->directory = PathResolver::getInstance()->getTmpDir($this, $directory);
     }
     $this->directory = $directory;
 }
 function __construct($customDirectory = null)
 {
     if (!$customDirectory) {
         $customDirectory = PathResolver::getInstance()->getTmpDir($this);
     }
     $this->directory = $customDirectory;
 }
 function make($file)
 {
     $cmd = new ShellCommand($this->executable, $this->winDir);
     $dbc = $this->getDBConnector();
     //force,skip possible errors
     $cmd->addArg(new ShellArg("-f"));
     $cmd->addArg(new ShellArg('-u', $dbc->getUser()));
     $cmd->addArg(new ShellArg('--password', $dbc->getPassword(), '='));
     $cmd->addArg(new ShellArg('-D', $dbc->getDbName()));
     $cmd->addArg(new ShellArg('-h', $dbc->getHost()));
     $cmd->addArg(new ShellArg("-q"));
     $cmd->addArg(new ShellArg("-s"));
     $cmd->addArg(new ShellArg(' < ', $file));
     $cmd->execute(PathResolver::getInstance()->getLogDir($this, $dbc->getDriver()->getName() . "." . $dbc->getName() . '.log'));
 }
 function make($storeStructure, $storeData)
 {
     $cmd = ShellCommand::create($this->executable, $this->winDir);
     $dbc = $this->getDBConnector();
     if ($storeData && !$storeStructure) {
         $cmd->addArg(ShellArg::create("--data-only"));
     }
     if ($storeStructure && !$storeData) {
         $cmd->addArg(ShellArg::create("--schema-only"));
     }
     $cmd->addArg(ShellArg::create("--clean"));
     //--column-inserts
     //$cmd->AddArg("-D");
     //target file
     $cmd->addArg(ShellArg::create("-f", $this->getTarget()));
     //--format=format
     $cmd->addArg(ShellArg::create('-F', 'p'));
     $cmd->addArg(ShellArg::create("--no-owner"));
     $cmd->addArg(ShellArg::create("--no-privileges"));
     //connection settings
     if ($dbc->getHost()) {
         $cmd->addArg(ShellArg::create('-h', $dbc->getHost()));
     }
     //dbname
     $cmd->addArg(ShellArg::create()->setValue($dbc->getDbName()));
     if (substr(PHP_OS, 0, 3) == 'WIN') {
         putenv('PGUSER='******'PGPASSWORD='******'env');
         $env->addArg(ShellArg::create()->setValue('PGUSER='******'PGPASSWORD='******'.log'));
 }
 function make($file)
 {
     $cmd = new ShellCommand($this->executable, $this->winDir);
     $dbc = $this->getDBConnector();
     if ($dbc->getHost()) {
         $cmd->AddArg("-h", $dbc->getHost());
     }
     $cmd->addArg(new ShellArg($dbc->getDbName()));
     $cmd->addArg(new ShellArg(' < ', $file));
     //we are to use local envvars because our magic dances with proc_open and writing
     //the password directly to the pipe failed
     if (substr(PHP_OS, 0, 3) == 'WIN') {
         putenv('PGUSER='******'PGPASSWORD='******'env');
         $env->addArg(ShellArg::create()->setValue('PGUSER='******'PGPASSWORD='******'.log'));
 }
 function execute($logPath = null)
 {
     $command = $this->getFullCommand();
     $out = shell_exec($command);
     if (!$logPath) {
         $logPath = PathResolver::getInstance()->getTmpDir($this, $this->getExecutableName() . '.txt');
     }
     file_put_contents($logPath, $command . PHP_EOL . $out);
     return $out;
 }
 /**
  * @return string
  */
 private function getCacheFilename()
 {
     return PathResolver::getInstance()->getTmpDir($this) . DIRECTORY_SEPARATOR . $this->getCacheId();
 }
 /**
  * Creates a temporary directory and returns a direct path to it
  * @throws FSOperationException
  * @param string $prefix
  * @return string
  */
 static function getTempDirectory($prefix = '')
 {
     Assert::isScalar($prefix);
     $directory = PathResolver::getInstance()->getTmpDir($prefix);
     $attempts = 5;
     $path = null;
     do {
         --$attempts;
         $path = $directory . DIRECTORY_SEPARATOR . $prefix . microtime(true) . mt_rand();
     } while (!mkdir($path, 0700, true) && $attempts > 0 && !usleep(100));
     if ($attempts == 0) {
         throw new FSOperationException("failed to create subdirectory in {$directory}");
     }
     return $path;
 }
 /**
  * Initializes the autoloader
  * @return void
  */
 private function initialize()
 {
     if ($this->isInitialized) {
         return;
     }
     $this->isInitialized = true;
     $cacheDirectory = PathResolver::getInstance()->getTmpDir($this);
     $this->mutexFilename = $cacheDirectory . DIRECTORY_SEPARATOR . $this->getMutexId() . '.mutex';
     if (!file_exists($this->mutexFilename)) {
         file_put_contents($this->mutexFilename, null);
     }
     $this->cacheFilename = $cacheDirectory . DIRECTORY_SEPARATOR . 'merged_' . sha1($this->slotId) . '_' . filemtime($this->mutexFilename) . '.php';
     return $this;
 }
Beispiel #10
0
 public static function path($path)
 {
     return PathResolver::getInstance()->getPath($path);
 }