remove OC_Filesystem::fromUploadedFile

This commit is contained in:
Robin Appelman 2011-11-08 22:36:05 +01:00
parent ca6c500799
commit 5cc6635eb8
6 changed files with 6 additions and 54 deletions

View File

@ -481,22 +481,6 @@ class OC_Filestorage_Shared extends OC_Filestorage {
}
}
public function fromUploadedFile($tmpFile, $path) {
if ($this->is_writeable($path)) {
$source = $this->getSource($path);
if ($source) {
$storage = OC_Filesystem::getStorage($source);
$result = $storage->fromUploadedFile($tmpFile, $this->getInternalPath($source));
if ($result) {
$this->clearFolderSizeCache($path);
}
return $result;
}
} else {
return false;
}
}
public function getMimeType($path) {
$source = $this->getSource($path);
if ($source) {

View File

@ -37,7 +37,7 @@ $sessionname = sha1('oc_file_hash_'.$path);
function do_save($path,$filecontents){
$sessionname = md5('oc_file_hash_'.$path);
OC_Filesystem::update_session_file_hash($sessionname,sha1(htmlspecialchars($filecontents)));
$_SESSION[$sessionname] = sha1(htmlspecialchars($filecontents));
OC_Filesystem::file_put_contents($path, $filecontents);
}

View File

@ -46,7 +46,7 @@ if(strpos($dir,'..') === false){
$fileCount=count($files['name']);
for($i=0;$i<$fileCount;$i++){
$target=stripslashes($dir) . $files['name'][$i];
if(OC_Filesystem::fromUploadedFile($files['tmp_name'][$i],$target)){
if(is_uploaded_file($files['tmp_name'][$i]) and OC_Filesystem::fromTmpFile($files['tmp_name'][$i],$target)){
$result[]=array( "status" => "success", 'mime'=>OC_Filesystem::getMimeType($target),'size'=>OC_Filesystem::filesize($target),'name'=>$files['name'][$i]);
}
}

View File

@ -47,7 +47,6 @@ class OC_Filestorage{
public function fopen($path,$mode){}
public function toTmpFile($path){}//copy the file to a temporary file, used for cross-storage file actions
public function fromTmpFile($tmpPath,$path){}//copy a file from a temporary file, used for cross-storage file actions
public function fromUploadedFile($tmpPath,$path){}//copy a file from a temporary file, used for cross-storage file actions
public function getMimeType($path){}
public function hash($type,$path,$raw){}
public function free_space($path){}

View File

@ -189,17 +189,6 @@ class OC_Filestorage_Local extends OC_Filestorage{
}
}
public function fromUploadedFile($tmpFile,$path){
$fileStats = stat($tmpFile);
if(move_uploaded_file($tmpFile,$this->datadir.$path)){
touch($this->datadir.$path, $fileStats['mtime'], $fileStats['atime']);
$this->clearFolderSizeCache($path);
return true;
}else{
return false;
}
}
private function delTree($dir) {
$dirRelative=$dir;
$dir=$this->datadir.$dir;

View File

@ -200,6 +200,10 @@ class OC_Filesystem{
}
}
/**
* following functions are equivilent to their php buildin equivilents for arguments/return values.
*/
static public function mkdir($path){
return self::basicOperation('mkdir',$path,array('create','write'));
}
@ -362,26 +366,6 @@ class OC_Filesystem{
}
}
}
static public function fromUploadedFile($tmpFile,$path){
if(OC_FileProxy::runPreProxies('fromUploadedFile',$tmpFile,$path) and self::canWrite($path) and $storage=self::getStorage($path)){
$run=true;
$exists=self::file_exists($path);
if(!$exists){
OC_Hook::emit( 'OC_Filesystem', 'create', array( 'path' => $path, 'run' => &$run));
}
if($run){
OC_Hook::emit( 'OC_Filesystem', 'write', array( 'path' => $path, 'run' => &$run));
}
if($run){
$result=$storage->fromUploadedFile($tmpFile,self::getInternalPath($path));
if(!$exists){
OC_Hook::emit( 'OC_Filesystem', 'post_create', array( 'path' => $path));
}
OC_Hook::emit( 'OC_Filesystem', 'post_write', array( 'path' => $path));
return $result;
}
}
}
static public function getMimeType($path){
return self::basicOperation('getMimeType',$path);
}
@ -413,10 +397,6 @@ class OC_Filesystem{
}
static public function update_session_file_hash($sessionname,$sessionvalue){
$_SESSION[$sessionname] = $sessionvalue;
}
/**
* abstraction for running most basic operations
* @param string $operation