示例#1
0
文件: Terminal.php 项目: Rhoban/deps
 public static function bold($message)
 {
     if (!OS::isWindows()) {
         echo "";
     }
     echo $message;
     if (!OS::isWindows()) {
         echo "";
     }
 }
示例#2
0
文件: Folder.php 项目: nochso/omni
 /**
  * deleteContents of a folder recursively, but not the folder itself.
  *
  * On Windows systems this will try to remove the read-only attribute if needed.
  *
  * @param string $path Path of folder whose contents will be deleted
  *
  * @throws \RuntimeException Thrown when something could not be deleted.
  */
 public static function deleteContents($path)
 {
     if (!is_dir($path)) {
         return;
     }
     /** @var \SplFileInfo[] $files */
     $files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST);
     foreach ($files as $fileInfo) {
         if ($fileInfo->isDir()) {
             if (@rmdir($fileInfo->getRealPath()) === false) {
                 throw new \RuntimeException(sprintf("Unable to delete child folder '%s' in '%s': %s", $fileInfo->getFilename(), $fileInfo->getPathname(), error_get_last()['message']));
             }
         } elseif (@unlink($fileInfo->getRealPath()) === false) {
             if (OS::isWindows()) {
                 Exec::create('attrib', '-R', $fileInfo->getRealPath())->run();
                 if (@unlink($fileInfo->getPathname())) {
                     continue;
                 }
             }
             throw new \RuntimeException(sprintf("Unable to delete file '%s' in folder '%s': %s", $fileInfo->getFilename(), $fileInfo->getPathname(), error_get_last()['message']));
         }
     }
 }
示例#3
0
文件: Exec.php 项目: nochso/omni
 /**
  * @param string $argument
  *
  * @return string
  */
 private function escapeArgument($argument)
 {
     // Always escape an empty argument so it doesn't get lost.
     if ($argument === '') {
         return escapeshellarg($argument);
     }
     if (!OS::isWindows()) {
         return $this->escapeLinuxArgument($argument);
     }
     return $this->escapeWindowsArgument($argument);
 }