use \OC\Files\Filesystem::isIgnoredDir

This commit is contained in:
Robin Appelman 2013-07-01 19:12:48 +02:00
parent 1302602173
commit d15ed9b4d3
3 changed files with 86 additions and 62 deletions

View File

@ -165,7 +165,7 @@ abstract class Common implements \OC\Files\Storage\Storage {
$dir = $this->opendir($path1);
$this->mkdir($path2);
while ($file = readdir($dir)) {
if (($file != '.') && ($file != '..')) {
if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
if (!$this->copy($path1 . '/' . $file, $path2 . '/' . $file)) {
return false;
}

View File

@ -196,7 +196,7 @@ if (\OC_Util::runningOnWindows()) {
$dir = $this->opendir($path1);
$this->mkdir($path2);
while ($file = readdir($dir)) {
if (($file != '.') && ($file != '..')) {
if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
if (!$this->copy($path1 . '/' . $file, $path2 . '/' . $file)) {
return false;
}

View File

@ -22,17 +22,21 @@ class MappedLocal extends \OC\Files\Storage\Common{
$this->mapper = new \OC\Files\Mapper($this->datadir);
}
public function __destruct() {
if (defined('PHPUNIT_RUN')) {
$this->mapper->removePath($this->datadir, true, true);
}
}
public function getId() {
return 'local::' . $this->datadir;
}
public function mkdir($path) {
return @mkdir($this->buildPath($path), 0777, true);
}
public function rmdir($path) {
try {
$it = new \RecursiveIteratorIterator(
@ -68,6 +72,7 @@ class MappedLocal extends \OC\Files\Storage\Common{
return false;
}
}
public function opendir($path) {
$files = array('.', '..');
$physicalPath = $this->buildPath($path);
@ -91,15 +96,18 @@ class MappedLocal extends \OC\Files\Storage\Common{
\OC\Files\Stream\Dir::register('local-win32' . $path, $files);
return opendir('fakedir://local-win32' . $path);
}
public function is_dir($path) {
if (substr($path, -1) == '/') {
$path = substr($path, 0, -1);
}
return is_dir($this->buildPath($path));
}
public function is_file($path) {
return is_file($this->buildPath($path));
}
public function stat($path) {
$fullPath = $this->buildPath($path);
$statResult = stat($fullPath);
@ -111,6 +119,7 @@ class MappedLocal extends \OC\Files\Storage\Common{
}
return $statResult;
}
public function filetype($path) {
$filetype = filetype($this->buildPath($path));
if ($filetype == 'link') {
@ -118,6 +127,7 @@ class MappedLocal extends \OC\Files\Storage\Common{
}
return $filetype;
}
public function filesize($path) {
if ($this->is_dir($path)) {
return 0;
@ -131,18 +141,23 @@ class MappedLocal extends \OC\Files\Storage\Common{
return $fileSize;
}
}
public function isReadable($path) {
return is_readable($this->buildPath($path));
}
public function isUpdatable($path) {
return is_writable($this->buildPath($path));
}
public function file_exists($path) {
return file_exists($this->buildPath($path));
}
public function filemtime($path) {
return filemtime($this->buildPath($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.
@ -158,15 +173,19 @@ class MappedLocal extends \OC\Files\Storage\Common{
return $result;
}
public function file_get_contents($path) {
return file_get_contents($this->buildPath($path));
}
public function file_put_contents($path, $data) {
return file_put_contents($this->buildPath($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);
@ -192,6 +211,7 @@ class MappedLocal extends \OC\Files\Storage\Common{
}
return $return;
}
public function copy($path1, $path2) {
if ($this->is_dir($path1)) {
if ($this->is_dir($path2)) {
@ -202,7 +222,7 @@ class MappedLocal extends \OC\Files\Storage\Common{
$dir = $this->opendir($path1);
$this->mkdir($path2);
while ($file = readdir($dir)) {
if (($file != '.') && ($file != '..')) {
if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
if (!$this->copy($path1 . '/' . $file, $path2 . '/' . $file)) {
return false;
}
@ -217,6 +237,7 @@ class MappedLocal extends \OC\Files\Storage\Common{
return $return;
}
}
public function fopen($path, $mode) {
if ($return = fopen($this->buildPath($path), $mode)) {
switch ($mode) {
@ -313,9 +334,11 @@ class MappedLocal extends \OC\Files\Storage\Common{
public function search($query) {
return $this->searchInDir($query);
}
public function getLocalFile($path) {
return $this->buildPath($path);
}
public function getLocalFolder($path) {
return $this->buildPath($path);
}
@ -344,6 +367,7 @@ class MappedLocal extends \OC\Files\Storage\Common{
/**
* check if a file or folder has been updated since $time
*
* @param string $path
* @param int $time
* @return bool