Skip to content

Commit

Permalink
Rebuilding...
Browse files Browse the repository at this point in the history
  • Loading branch information
kohkimakimoto committed Oct 28, 2014
1 parent 0994599 commit d38e547
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/Altax/Filesystem/Filesystem.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php
namespace Altax\Filesystem;

use Altax\Process\NodeProcess;

class Filesystem
{
protected $commandBuilder;
Expand All @@ -19,4 +21,23 @@ public function __construct($commandBuilder, $process, $output)
$this->node = $process->getNode();
$this->output = $output;
}

public function exists($path)
{
$command = $this->commandBuilder->make("test -e $path");
$verbosity = $command->getOutput()->getVerbosity();

// Prevents to display command output.
$command->getOutput()->setVerbosity(0);
$ret = $command->run()->isSuccessful();
$command->getOutput()->setVerbosity($verbosity);

if ($ret) {
$this->output->writeln("<info>Check file: </info>$path (exists)".$this->process->getNodeInfo());
} else {
$this->output->writeln("<info>Check file: </info>$path (not exists)".$this->process->getNodeInfo());
}

return $ret;
}
}
5 changes: 5 additions & 0 deletions src/Altax/Filesystem/FilesystemBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ public function make()
$this->output
);
}

public function exists($path)
{
return $this->make()->exists($path);
}
}
13 changes: 13 additions & 0 deletions src/Altax/Filesystem/LocalFilesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,17 @@ public function __construct($commandBuilder, $process, $output)
$this->process = $process;
$this->output = $output;
}

public function exists($path)
{
$ret = file_exists($path);

if ($ret) {
$this->output->writeln("<info>Check file: </info>$path (exists)");
} else {
$this->output->writeln("<info>Check file: </info>$path (not exists)");
}

return $ret;
}
}
6 changes: 6 additions & 0 deletions src/Altax/Filesystem/LocalFilesystemBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,10 @@ public function make()
$this->output
);
}

public function exists($path)
{
return $this->make()->exists($path);
}

}
5 changes: 5 additions & 0 deletions src/Altax/Shell/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,9 @@ public function setOption($key, $value)

return $this;
}

public function getOutput()
{
return $this->output;
}
}

0 comments on commit d38e547

Please sign in to comment.