Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
467e9c2b
Commit
467e9c2b
authored
11 years ago
by
Robin Appelman
Browse files
Options
Downloads
Patches
Plain Diff
Remove code duplication
parent
af35b6ad
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/private/files/storage/common.php
+21
-20
21 additions, 20 deletions
lib/private/files/storage/common.php
with
21 additions
and
20 deletions
lib/private/files/storage/common.php
+
21
−
20
View file @
467e9c2b
...
...
@@ -7,6 +7,7 @@
*/
namespace
OC\Files\Storage
;
use
OC\Files\Filesystem
;
use
OC\Files\Cache\Watcher
;
/**
...
...
@@ -36,6 +37,22 @@ abstract class Common implements \OC\Files\Storage\Storage {
public
function
__construct
(
$parameters
)
{
}
/**
* Remove a file of folder
*
* @param string $path
* @return bool
*/
protected
function
remove
(
$path
)
{
if
(
$this
->
is_dir
(
$path
))
{
return
$this
->
rmdir
(
$path
);
}
else
if
(
$this
->
is_file
(
$path
))
{
return
$this
->
unlink
(
$path
);
}
else
{
return
false
;
}
}
public
function
is_dir
(
$path
)
{
return
$this
->
filetype
(
$path
)
==
'dir'
;
}
...
...
@@ -137,35 +154,19 @@ abstract class Common implements \OC\Files\Storage\Storage {
}
public
function
rename
(
$path1
,
$path2
)
{
if
(
$this
->
file_exists
(
$path2
))
{
if
(
$this
->
is_dir
(
$path2
))
{
$this
->
rmdir
(
$path2
);
}
else
{
$this
->
unlink
(
$path2
);
}
}
$this
->
remove
(
$path2
);
$this
->
removeCachedFile
(
$path1
);
if
(
$this
->
is_dir
(
$path1
))
{
return
$this
->
copy
(
$path1
,
$path2
)
and
$this
->
rmdir
(
$path1
);
}
else
{
return
$this
->
copy
(
$path1
,
$path2
)
and
$this
->
unlink
(
$path1
);
}
return
$this
->
copy
(
$path1
,
$path2
)
and
$this
->
remove
(
$path1
);
}
public
function
copy
(
$path1
,
$path2
)
{
if
(
$this
->
is_dir
(
$path1
))
{
if
(
$this
->
file_exists
(
$path2
))
{
if
(
$this
->
is_dir
(
$path2
))
{
$this
->
rmdir
(
$path2
);
}
else
{
$this
->
unlink
(
$path2
);
}
}
$this
->
remove
(
$path2
);
$dir
=
$this
->
opendir
(
$path1
);
$this
->
mkdir
(
$path2
);
while
(
$file
=
readdir
(
$dir
))
{
if
(
!
\OC\Files\
Filesystem
::
isIgnoredDir
(
$file
))
{
if
(
!
Filesystem
::
isIgnoredDir
(
$file
))
{
if
(
!
$this
->
copy
(
$path1
.
'/'
.
$file
,
$path2
.
'/'
.
$file
))
{
return
false
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment