/**
  * @param FileInterface $file
  * @param               $newName
  *
  * @return FileInterface
  */
 public function renameFile(FileInterface $file, $newName)
 {
     if (@rename($file->getPath(), $file->getParentFolder() . "/" . $newName)) {
         return true;
     }
     return false;
 }
Beispiel #2
0
 /**
  * @param FileInterface $file
  * @return FileInterface
  * @throws \Exception
  */
 public function updateFileInDb(FileInterface $file)
 {
     /**
      * @var $file File
      */
     $update = $this->pdo->prepare('UPDATE files SET
     name = :name,
     size = :size,
     modified_time = :modified_time,
     path = :path,
     folder_id = :folder_id
     WHERE id = :id');
     $modified_time = $file->getModifiedTime() ? $file->getModifiedTime()->format('Y-m-d H:i:s') : null;
     try {
         $update->execute(array('name' => $file->getName(), 'size' => $file->getSize(), 'modified_time' => $modified_time, 'path' => $file->getPath(), 'folder_id' => $file->getParentFolder()->getId(), 'id' => $file->getId()));
     } catch (\Exception $ex) {
         throw new \Exception('Updating file failed');
     }
     return $file;
 }