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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
f5b62267
Commit
f5b62267
authored
10 years ago
by
Thomas Müller
Browse files
Options
Downloads
Plain Diff
Merge pull request #14462 from owncloud/add-some-php-docs
Add some PHPDocs
parents
f6044fe4
dbb665a3
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
apps/files_external/lib/sftp.php
+70
-2
70 additions, 2 deletions
apps/files_external/lib/sftp.php
with
70 additions
and
2 deletions
apps/files_external/lib/sftp.php
+
70
−
2
View file @
f5b62267
...
@@ -44,8 +44,9 @@ class SFTP extends \OC\Files\Storage\Common {
...
@@ -44,8 +44,9 @@ class SFTP extends \OC\Files\Storage\Common {
*/
*/
protected
$client
;
protected
$client
;
private
static
$tempFiles
=
array
();
/**
* {@inheritdoc}
*/
public
function
__construct
(
$params
)
{
public
function
__construct
(
$params
)
{
// Register sftp://
// Register sftp://
\Net_SFTP_Stream
::
register
();
\Net_SFTP_Stream
::
register
();
...
@@ -112,6 +113,9 @@ class SFTP extends \OC\Files\Storage\Common {
...
@@ -112,6 +113,9 @@ class SFTP extends \OC\Files\Storage\Common {
return
$this
->
client
;
return
$this
->
client
;
}
}
/**
* {@inheritdoc}
*/
public
function
test
()
{
public
function
test
()
{
if
(
if
(
!
isset
(
$this
->
host
)
!
isset
(
$this
->
host
)
...
@@ -123,29 +127,45 @@ class SFTP extends \OC\Files\Storage\Common {
...
@@ -123,29 +127,45 @@ class SFTP extends \OC\Files\Storage\Common {
return
$this
->
getConnection
()
->
nlist
()
!==
false
;
return
$this
->
getConnection
()
->
nlist
()
!==
false
;
}
}
/**
* {@inheritdoc}
*/
public
function
getId
(){
public
function
getId
(){
return
'sftp::'
.
$this
->
user
.
'@'
.
$this
->
host
.
':'
.
$this
->
port
.
'/'
.
$this
->
root
;
return
'sftp::'
.
$this
->
user
.
'@'
.
$this
->
host
.
':'
.
$this
->
port
.
'/'
.
$this
->
root
;
}
}
/**
* @return string
*/
public
function
getHost
()
{
public
function
getHost
()
{
return
$this
->
host
;
return
$this
->
host
;
}
}
/**
* @return string
*/
public
function
getRoot
()
{
public
function
getRoot
()
{
return
$this
->
root
;
return
$this
->
root
;
}
}
/**
* @return mixed
*/
public
function
getUser
()
{
public
function
getUser
()
{
return
$this
->
user
;
return
$this
->
user
;
}
}
/**
/**
* @param string $path
* @param string $path
* @return string
*/
*/
private
function
absPath
(
$path
)
{
private
function
absPath
(
$path
)
{
return
$this
->
root
.
$this
->
cleanPath
(
$path
);
return
$this
->
root
.
$this
->
cleanPath
(
$path
);
}
}
/**
* @return bool|string
*/
private
function
hostKeysPath
()
{
private
function
hostKeysPath
()
{
try
{
try
{
$storage_view
=
\OCP\Files
::
getStorage
(
'files_external'
);
$storage_view
=
\OCP\Files
::
getStorage
(
'files_external'
);
...
@@ -159,6 +179,10 @@ class SFTP extends \OC\Files\Storage\Common {
...
@@ -159,6 +179,10 @@ class SFTP extends \OC\Files\Storage\Common {
return
false
;
return
false
;
}
}
/**
* @param $keys
* @return bool
*/
protected
function
writeHostKeys
(
$keys
)
{
protected
function
writeHostKeys
(
$keys
)
{
try
{
try
{
$keyPath
=
$this
->
hostKeysPath
();
$keyPath
=
$this
->
hostKeysPath
();
...
@@ -175,6 +199,9 @@ class SFTP extends \OC\Files\Storage\Common {
...
@@ -175,6 +199,9 @@ class SFTP extends \OC\Files\Storage\Common {
return
false
;
return
false
;
}
}
/**
* @return array
*/
protected
function
readHostKeys
()
{
protected
function
readHostKeys
()
{
try
{
try
{
$keyPath
=
$this
->
hostKeysPath
();
$keyPath
=
$this
->
hostKeysPath
();
...
@@ -198,6 +225,9 @@ class SFTP extends \OC\Files\Storage\Common {
...
@@ -198,6 +225,9 @@ class SFTP extends \OC\Files\Storage\Common {
return
array
();
return
array
();
}
}
/**
* {@inheritdoc}
*/
public
function
mkdir
(
$path
)
{
public
function
mkdir
(
$path
)
{
try
{
try
{
return
$this
->
getConnection
()
->
mkdir
(
$this
->
absPath
(
$path
));
return
$this
->
getConnection
()
->
mkdir
(
$this
->
absPath
(
$path
));
...
@@ -206,6 +236,9 @@ class SFTP extends \OC\Files\Storage\Common {
...
@@ -206,6 +236,9 @@ class SFTP extends \OC\Files\Storage\Common {
}
}
}
}
/**
* {@inheritdoc}
*/
public
function
rmdir
(
$path
)
{
public
function
rmdir
(
$path
)
{
try
{
try
{
return
$this
->
getConnection
()
->
delete
(
$this
->
absPath
(
$path
),
true
);
return
$this
->
getConnection
()
->
delete
(
$this
->
absPath
(
$path
),
true
);
...
@@ -214,6 +247,9 @@ class SFTP extends \OC\Files\Storage\Common {
...
@@ -214,6 +247,9 @@ class SFTP extends \OC\Files\Storage\Common {
}
}
}
}
/**
* {@inheritdoc}
*/
public
function
opendir
(
$path
)
{
public
function
opendir
(
$path
)
{
try
{
try
{
$list
=
$this
->
getConnection
()
->
nlist
(
$this
->
absPath
(
$path
));
$list
=
$this
->
getConnection
()
->
nlist
(
$this
->
absPath
(
$path
));
...
@@ -235,6 +271,9 @@ class SFTP extends \OC\Files\Storage\Common {
...
@@ -235,6 +271,9 @@ class SFTP extends \OC\Files\Storage\Common {
}
}
}
}
/**
* {@inheritdoc}
*/
public
function
filetype
(
$path
)
{
public
function
filetype
(
$path
)
{
try
{
try
{
$stat
=
$this
->
getConnection
()
->
stat
(
$this
->
absPath
(
$path
));
$stat
=
$this
->
getConnection
()
->
stat
(
$this
->
absPath
(
$path
));
...
@@ -251,6 +290,9 @@ class SFTP extends \OC\Files\Storage\Common {
...
@@ -251,6 +290,9 @@ class SFTP extends \OC\Files\Storage\Common {
return
false
;
return
false
;
}
}
/**
* {@inheritdoc}
*/
public
function
file_exists
(
$path
)
{
public
function
file_exists
(
$path
)
{
try
{
try
{
return
$this
->
getConnection
()
->
stat
(
$this
->
absPath
(
$path
))
!==
false
;
return
$this
->
getConnection
()
->
stat
(
$this
->
absPath
(
$path
))
!==
false
;
...
@@ -259,6 +301,9 @@ class SFTP extends \OC\Files\Storage\Common {
...
@@ -259,6 +301,9 @@ class SFTP extends \OC\Files\Storage\Common {
}
}
}
}
/**
* {@inheritdoc}
*/
public
function
unlink
(
$path
)
{
public
function
unlink
(
$path
)
{
try
{
try
{
return
$this
->
getConnection
()
->
delete
(
$this
->
absPath
(
$path
),
true
);
return
$this
->
getConnection
()
->
delete
(
$this
->
absPath
(
$path
),
true
);
...
@@ -267,6 +312,9 @@ class SFTP extends \OC\Files\Storage\Common {
...
@@ -267,6 +312,9 @@ class SFTP extends \OC\Files\Storage\Common {
}
}
}
}
/**
* {@inheritdoc}
*/
public
function
fopen
(
$path
,
$mode
)
{
public
function
fopen
(
$path
,
$mode
)
{
try
{
try
{
$absPath
=
$this
->
absPath
(
$path
);
$absPath
=
$this
->
absPath
(
$path
);
...
@@ -296,6 +344,9 @@ class SFTP extends \OC\Files\Storage\Common {
...
@@ -296,6 +344,9 @@ class SFTP extends \OC\Files\Storage\Common {
return
false
;
return
false
;
}
}
/**
* {@inheritdoc}
*/
public
function
touch
(
$path
,
$mtime
=
null
)
{
public
function
touch
(
$path
,
$mtime
=
null
)
{
try
{
try
{
if
(
!
is_null
(
$mtime
))
{
if
(
!
is_null
(
$mtime
))
{
...
@@ -312,14 +363,27 @@ class SFTP extends \OC\Files\Storage\Common {
...
@@ -312,14 +363,27 @@ class SFTP extends \OC\Files\Storage\Common {
return
true
;
return
true
;
}
}
/**
* @param string $path
* @param string $target
* @throws \Exception
*/
public
function
getFile
(
$path
,
$target
)
{
public
function
getFile
(
$path
,
$target
)
{
$this
->
getConnection
()
->
get
(
$path
,
$target
);
$this
->
getConnection
()
->
get
(
$path
,
$target
);
}
}
/**
* @param string $path
* @param string $target
* @throws \Exception
*/
public
function
uploadFile
(
$path
,
$target
)
{
public
function
uploadFile
(
$path
,
$target
)
{
$this
->
getConnection
()
->
put
(
$target
,
$path
,
NET_SFTP_LOCAL_FILE
);
$this
->
getConnection
()
->
put
(
$target
,
$path
,
NET_SFTP_LOCAL_FILE
);
}
}
/**
* {@inheritdoc}
*/
public
function
rename
(
$source
,
$target
)
{
public
function
rename
(
$source
,
$target
)
{
try
{
try
{
if
(
!
$this
->
is_dir
(
$target
)
&&
$this
->
file_exists
(
$target
))
{
if
(
!
$this
->
is_dir
(
$target
)
&&
$this
->
file_exists
(
$target
))
{
...
@@ -334,6 +398,9 @@ class SFTP extends \OC\Files\Storage\Common {
...
@@ -334,6 +398,9 @@ class SFTP extends \OC\Files\Storage\Common {
}
}
}
}
/**
* {@inheritdoc}
*/
public
function
stat
(
$path
)
{
public
function
stat
(
$path
)
{
try
{
try
{
$stat
=
$this
->
getConnection
()
->
stat
(
$this
->
absPath
(
$path
));
$stat
=
$this
->
getConnection
()
->
stat
(
$this
->
absPath
(
$path
));
...
@@ -349,6 +416,7 @@ class SFTP extends \OC\Files\Storage\Common {
...
@@ -349,6 +416,7 @@ class SFTP extends \OC\Files\Storage\Common {
/**
/**
* @param string $path
* @param string $path
* @return string
*/
*/
public
function
constructUrl
(
$path
)
{
public
function
constructUrl
(
$path
)
{
// Do not pass the password here. We want to use the Net_SFTP object
// Do not pass the password here. We want to use the Net_SFTP object
...
...
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