From e76e4e75407cc672bf342f13bbd77392a93c1623 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 29 Feb 2012 23:42:40 +0100 Subject: add touch() to all storage backands, and make parameter optional --- lib/filestorage/common.php | 1 + lib/filestorage/commontest.php | 3 +++ lib/filestorage/local.php | 11 ++++++++--- 3 files changed, 12 insertions(+), 3 deletions(-) (limited to 'lib/filestorage') diff --git a/lib/filestorage/common.php b/lib/filestorage/common.php index 40a9cff5d06..fa14d7e99fd 100644 --- a/lib/filestorage/common.php +++ b/lib/filestorage/common.php @@ -121,4 +121,5 @@ abstract class OC_Filestorage_Common extends OC_Filestorage { $count=OC_Helper::streamCopy($source,$target); return $tmpFile; } +// abstract public function touch($path, $mtime=null); } diff --git a/lib/filestorage/commontest.php b/lib/filestorage/commontest.php index dd552c6865b..512e7c1b66d 100644 --- a/lib/filestorage/commontest.php +++ b/lib/filestorage/commontest.php @@ -72,4 +72,7 @@ class OC_Filestorage_CommonTest extends OC_Filestorage_Common{ public function search($query){ return $this->storage->search($query); } + public function touch($path, $mtime=null){ + return $this->storage->touch($path,$mtime); + } } \ No newline at end of file diff --git a/lib/filestorage/local.php b/lib/filestorage/local.php index 8acfe504cb2..8e07ce6025b 100644 --- a/lib/filestorage/local.php +++ b/lib/filestorage/local.php @@ -58,15 +58,20 @@ class OC_Filestorage_Local extends OC_Filestorage{ public function filemtime($path){ return filemtime($this->datadir.$path); } - public function touch($path, $mtime){ + public function touch($path, $mtime=null){ // sets the modification time of the file to the given value. // If mtime is nil the current time is set. // note that the access time of the file always changes to the current time. - if( touch( $this->datadir.$path, $mtime ) ) { + if(!is_null($mtime)){ + $result=touch( $this->datadir.$path, $mtime ); + }else{ + $result=touch( $this->datadir.$path); + } + if( $result ) { clearstatcache( true, $this->datadir.$path ); } - return touch($this->datadir.$path, $mtime); + return $result; } public function file_get_contents($path){ return file_get_contents($this->datadir.$path); -- cgit v1.2.3