/** * Rename a normal file to a db file * * @access public * * @param $path file from path * @param $pi the pi of the db entry */ public static function renameToDb($path, $pi) { Log::in("query - renameToDb - path is - {$path}"); $dbConn = Pool::get(); /* Get the query properties */ $tableType = $pi[PI_TI]; $table = $tableType[TI_TABLE]; $name = $tableType[TI_NAMEFIELD]; $prefix = Pool::getTableprefix(); $toFilename = $pi[PI_FILENAME]; /* Get the from file name */ $fromFilename = basename($path); $fromFilenameArray = explode('.', $fromFilename); $fromFilename = $fromFilenameArray[0]; Log::output("query - renameToDb - create sql"); $sql = "UPDATE "; $sql .= "`{$prefix}" . "{$table}`"; $sql .= " SET {$name} = '{$toFilename}'"; $sql .= " WHERE {$name} = '{$fromFilename}'"; Log::output($sql); /* Check for failure */ Log::output("query - renameToDb - check for failure"); $result = mysql_query($sql, $dbConn); $rows = mysql_affected_rows($dbConn); if ($result === false || $rows == 0) { /* If no rows, create the entity */ if ($rows == 0) { Log::output("query - renameToDb - creating entity"); $buf = file_get_contents($path); $size = strlen($buf); $ret = Query::mknod($pi); if ($ret != 0) { Pool::release($dbConn); Log::out("query - renameToDb failed - cannot create entity"); return -FUSE_EIO; } Query::fillContentId($pi, 0); Query::Write($pi, $buf, $size, 0); Pool::release($dbConn); Log::out("query - renameToDb - create - OK"); return 0; } /* Otherwise process the error */ $error = mysql_error($dbConn); Log::output($error); Pool::release($dbConn); Log::out("query - renameToDb failed"); return -FUSE_EIO; } Pool::release($dbConn); Log::out("query - renameToDb"); return 0; }
/** * Make a directory * * @access public * * @param $path file path * @param $mode directory mode */ function mkdir($path, $mode) { Log::in("MKDIR"); /* Check for passthru */ if (PassThru::check($path)) { $ret = PassThru::mkdir($path, $mode); } else { /* Ok, we can only make categories, let mknod do this */ $pi = Query::pathInfo($path); $ret = Query::mknod($pi); } Log::out("MKDIR"); return $ret; }