示例#1
0
 public function getFileFingerprint($file)
 {
     $output = array();
     $returnCode = 0;
     //Make sure the file exists and is readable
     if (!file_exists($file) || !is_readable($file)) {
         return false;
     }
     $process = new Process($this->requirementDir . '/fpcalc ' . escapeshellarg($file));
     $process->run();
     //The return code is not 0 (success), return false
     if ($returnCode !== 0) {
         return false;
     }
     $output = explode("\n", $process->getoutput());
     $result = array();
     foreach ($output as $item) {
         if (empty($item)) {
             continue;
         }
         $temp = explode("=", $item);
         $result[strtolower($temp[0])] = $temp[1];
     }
     return $result;
 }