public function setHash(FileHash $fh) { $fn = $fh->getFilename(); $hash = $fh->getHash(); print_r($fn); foreach ($this->data->file as $file) { if ($file->name == $fn) { $file->hash = $hash; return TRUE; } } $db = $this->data[0]; $f = $db->addChild('file'); $f->addChild('name', $fn); $f->addChild('hash', $hash); }
/** * Stores the hash and filename specified by FileHash. Overwrites the stored hash, if it exists. * @param FileHash $fh */ public function setHash(FileHash $fh) { $fn = $fh->getFilename(); $hash = $fh->getHash(); $this->data[$fn] = $hash; }
/** * Compares the stored hash with the FileHash hash. * @param FileHash $fh * @return boolean Returns TRUE if the hashes match, FALSE if they are different. */ public function compareHash(FileHash $fh) { $oldhash = $this->getHash($fh->getFilename()); return $oldhash == $fh->getHash(); }