function _moveToNewPath($file_id)
 {
     $old_path = $this->_getFilePathOld($file_id);
     if (!is_file($old_path)) {
         return;
     }
     $new_path = $this->getFilePath($file_id);
     $dir = dirname($new_path);
     force_mkdir($dir, 0777);
     rename($old_path, $new_path);
     $this->_cleanUpDirOld($file_id);
     return $new_path;
 }
 /**
  * Add file to the repository
  *
  * @param string $source Path of the source file
  * @param array $attributes Array of file attributes
  * @return string File ID
  * @throws FileDnxError if source is not readable
  * @throws FailedToCreateFolderError if we fail to create subdirectory
  * @throws FileRepositoryAddError if we fail to move file to the repository
  */
 function addFile($source, $attributes = null)
 {
     if (!is_readable($source)) {
         throw new FileDnxError($source);
     }
     // if
     $file_id = $this->getUniqueId();
     $file_path = $this->_getFilePath($file_id);
     $destination_dir = dirname($file_path);
     if (!is_dir($destination_dir)) {
         if (!force_mkdir($destination_dir, 0777)) {
             throw new FailedToCreateFolderError($destination_dir);
         }
         // if
     }
     // if
     if (!copy($source, $file_path)) {
         throw new FileRepositoryAddError($source, $file_id);
     }
     // if
     $this->attributes[$file_id] = true;
     // register file
     if (is_array($attributes)) {
         foreach ($attributes as $attribute_name => $attribute_value) {
             $this->setFileAttribute($file_id, $attribute_name, $attribute_value);
         }
         // foreach
     }
     // if
     return $file_id;
 }