Ejemplo n.º 1
0
 /**
  * Tries to read the file $this->file, and to decode it as a KeePass 2.x
  * database, using the key $this->key. Returns true if the operation was
  * successful, or false otherwise. In case of success, the array
  * $this->entries will contain the resulting list of entries.
  *
  * @return boolean
  */
 public function tryLoad()
 {
     if ($this->loaded) {
         return $this->rawEntries != null;
     }
     $this->loaded = true;
     if (!is_file($this->file) || !is_readable($this->file)) {
         KeePassPHP::raiseError("Impossible to read " . $this->file);
         return false;
     }
     KeePassPHP::printDebug("Attempting to load database from " . $this->file);
     if (!$this->tryParse(RessourceReader::openFile($this->file))) {
         KeePassPHP::printDebug("  ... attempt failed !");
         return false;
     }
     KeePassPHP::printDebug("  ... attempt succeeded !");
     return true;
 }
Ejemplo n.º 2
0
 /**
  * Tries to read the file $this->file, and to decode it as a KeePass 2.x
  * database, using the key $this->key. Returns true if the operation was
  * successful, or false otherwise. In case of success, the array
  * $this->entries will contain the resulting list of entries.
  *
  * @return boolean
  */
 public function tryLoad()
 {
     if ($this->loaded) {
         return $this->rawEntries != null;
     }
     $this->loaded = true;
     if (!\OC\Files\Filesystem::file_exists($this->file)) {
         KeePassPHP::raiseError("Impossible to read " . $this->file);
         return false;
     }
     KeePassPHP::printDebug("Attempting to load database from " . $this->file);
     $resReader = RessourceReader::openFile($this->file);
     if (!$resReader) {
         KeePassPHP::raiseError("Unable to open file " . $this->file);
         return false;
     }
     if (!$this->tryParse($resReader)) {
         KeePassPHP::printDebug("  ... attempt failed !");
         return false;
     }
     KeePassPHP::printDebug("  ... attempt succeeded !");
     return true;
 }