Example #1
0
 /**
  * Tests if a given file exists on the remote server
  * @param \Cogeco\Build\Entity\File $file
  * @return bool
  */
 public static function fileExists(File $file)
 {
     // Make sure there is a connection
     if (!$file->isRemote()) {
         echo "Warning: Testing for file existence on local machine rather than a remote one";
         return file_exists($file->getPath());
     }
     $command = '[ -f ' . $file->getPath() . ' ] && echo "1" || echo "0"';
     $ssh = self::connect($file->getHost());
     $output = trim($ssh->exec($command));
     self::checkCmdExceptions($ssh);
     return $output === "1";
 }