Example #1
0
 /**
  * Rename a file
  *
  * @access public
  *
  * @param $pathFrom from file
  * @param $pathTo to file
  */
 function rename($pathFrom, $pathTo)
 {
     Log::in("RENAME");
     Log::output("From {$pathFrom}");
     Log::output("To {$pathTo}");
     $localPathFrom = $pathFrom;
     $localPathTo = $pathTo;
     /* Check for a complete passthru rename */
     if (PassThru::check($localPathTo) && PassThru::check($localPathFrom)) {
         $ret = PassThru::rename($localPathFrom, $localPathTo);
         Log::out("RENAME");
         return $ret;
     }
     /* OK, we either have a passthru to db case, or a db to passthru case */
     $localPathFrom = $pathFrom;
     $localPathTo = $pathTo;
     /* Passthru to db */
     if (PassThru::check($localPathFrom)) {
         /* Get the to path as a pi */
         $toPi = Query::pathInfo($pathTo);
         /* Check the paths have filenames */
         Log::output("RENAME - checking filenames");
         if (!is_file($localPathFrom) || $toPi[PI_LEVEL] != PL_FILENAME) {
             Log::out("RENAME - filename(s) invalid - failed");
             return -FUSE_ENOENT;
         }
         /* Unlink the to file */
         Log::output("RENAME - unlink the to file");
         Query::unlink($toPi);
         /* Do the rename */
         Log::output("RENAME - calling query - Passthrutodb");
         $ret = Query::renameToDb($localPathFrom, $toPi);
         Log::out("RENAME");
         return $ret;
     }
     /* Db to passthru */
     if (PassThru::check($localPathTo)) {
         /* Get the from path as a pi */
         $fromPi = Query::pathInfo($pathFrom);
         /* Check the paths have filenames */
         Log::output("RENAME - checking filenames");
         if (!is_file($localPathTo) || $fromPi[PI_LEVEL] != PL_FILENAME) {
             Log::out("RENAME - filename(s) invalid - failed");
             return -FUSE_ENOENT;
         }
         /* Unlink the from file */
         Log::output("RENAME - unlink the from file");
         Query::unlink($fromPi);
         /* Do the rename */
         Log::output("RENAME - calling query - Dbtopassthru");
         $ret = Query::renameToPassthru($localPathTo, $fromPi);
         Log::out("RENAME");
         return $ret;
     }
     /* Database only rename */
     Log::output("RENAME - calling query - dbtodb");
     $fromPi = Query::pathInfo($pathFrom);
     $ret = Query::renameInDb($fromPi, $pathTo);
     Log::out("RENAME");
     return $ret;
 }