Code style
This commit is contained in:
parent
5474fea1f6
commit
8a838e0e03
|
@ -19,35 +19,44 @@ if (\OC_Util::runningOnWindows()) {
|
|||
*/
|
||||
class Local extends \OC\Files\Storage\Common {
|
||||
protected $datadir;
|
||||
|
||||
public function __construct($arguments) {
|
||||
$this->datadir = $arguments['datadir'];
|
||||
if (substr($this->datadir, -1) !== '/') {
|
||||
$this->datadir .= '/';
|
||||
}
|
||||
}
|
||||
|
||||
public function __destruct() {
|
||||
}
|
||||
|
||||
public function getId() {
|
||||
return 'local::' . $this->datadir;
|
||||
}
|
||||
|
||||
public function mkdir($path) {
|
||||
return @mkdir($this->datadir . $path);
|
||||
}
|
||||
|
||||
public function rmdir($path) {
|
||||
return @rmdir($this->datadir . $path);
|
||||
}
|
||||
|
||||
public function opendir($path) {
|
||||
return opendir($this->datadir . $path);
|
||||
}
|
||||
|
||||
public function is_dir($path) {
|
||||
if (substr($path, -1) == '/') {
|
||||
$path = substr($path, 0, -1);
|
||||
}
|
||||
return is_dir($this->datadir . $path);
|
||||
}
|
||||
|
||||
public function is_file($path) {
|
||||
return is_file($this->datadir . $path);
|
||||
}
|
||||
|
||||
public function stat($path) {
|
||||
$fullPath = $this->datadir . $path;
|
||||
$statResult = stat($fullPath);
|
||||
|
@ -59,6 +68,7 @@ class Local extends \OC\Files\Storage\Common{
|
|||
}
|
||||
return $statResult;
|
||||
}
|
||||
|
||||
public function filetype($path) {
|
||||
$filetype = filetype($this->datadir . $path);
|
||||
if ($filetype == 'link') {
|
||||
|
@ -66,6 +76,7 @@ class Local extends \OC\Files\Storage\Common{
|
|||
}
|
||||
return $filetype;
|
||||
}
|
||||
|
||||
public function filesize($path) {
|
||||
if ($this->is_dir($path)) {
|
||||
return 0;
|
||||
|
@ -79,18 +90,23 @@ class Local extends \OC\Files\Storage\Common{
|
|||
return $fileSize;
|
||||
}
|
||||
}
|
||||
|
||||
public function isReadable($path) {
|
||||
return is_readable($this->datadir . $path);
|
||||
}
|
||||
|
||||
public function isUpdatable($path) {
|
||||
return is_writable($this->datadir . $path);
|
||||
}
|
||||
|
||||
public function file_exists($path) {
|
||||
return file_exists($this->datadir . $path);
|
||||
}
|
||||
|
||||
public function filemtime($path) {
|
||||
return filemtime($this->datadir . $path);
|
||||
}
|
||||
|
||||
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.
|
||||
|
@ -109,15 +125,19 @@ class Local extends \OC\Files\Storage\Common{
|
|||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function file_get_contents($path) {
|
||||
return file_get_contents($this->datadir . $path);
|
||||
}
|
||||
|
||||
public function file_put_contents($path, $data) { //trigger_error("$path = ".var_export($path, 1));
|
||||
return file_put_contents($this->datadir . $path, $data);
|
||||
}
|
||||
|
||||
public function unlink($path) {
|
||||
return $this->delTree($path);
|
||||
}
|
||||
|
||||
public function rename($path1, $path2) {
|
||||
if (!$this->isUpdatable($path1)) {
|
||||
\OC_Log::write('core', 'unable to rename, file is not writable : ' . $path1, \OC_Log::ERROR);
|
||||
|
@ -132,6 +152,7 @@ class Local extends \OC\Files\Storage\Common{
|
|||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function copy($path1, $path2) {
|
||||
if ($this->is_dir($path2)) {
|
||||
if (!$this->file_exists($path2)) {
|
||||
|
@ -142,6 +163,7 @@ class Local extends \OC\Files\Storage\Common{
|
|||
}
|
||||
return copy($this->datadir . $path1, $this->datadir . $path2);
|
||||
}
|
||||
|
||||
public function fopen($path, $mode) {
|
||||
if ($return = fopen($this->datadir . $path, $mode)) {
|
||||
switch ($mode) {
|
||||
|
@ -231,9 +253,11 @@ class Local extends \OC\Files\Storage\Common{
|
|||
public function search($query) {
|
||||
return $this->searchInDir($query);
|
||||
}
|
||||
|
||||
public function getLocalFile($path) {
|
||||
return $this->datadir . $path;
|
||||
}
|
||||
|
||||
public function getLocalFolder($path) {
|
||||
return $this->datadir . $path;
|
||||
}
|
||||
|
@ -254,6 +278,7 @@ class Local extends \OC\Files\Storage\Common{
|
|||
|
||||
/**
|
||||
* check if a file or folder has been updated since $time
|
||||
*
|
||||
* @param string $path
|
||||
* @param int $time
|
||||
* @return bool
|
||||
|
|
Loading…
Reference in New Issue