mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-03 09:14:06 +02:00
Extract share interface
This commit is contained in:
parent
eca03d1b88
commit
cc376a4b31
3 changed files with 104 additions and 3 deletions
101
src/IShare.php
Normal file
101
src/IShare.php
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
namespace Icewind\SMB;
|
||||
|
||||
interface IShare {
|
||||
public function connect();
|
||||
|
||||
/**
|
||||
* Create a folder on the share
|
||||
*
|
||||
* @param string $path
|
||||
* @return bool
|
||||
*/
|
||||
public function mkdir($path);
|
||||
|
||||
/**
|
||||
* Download a remote file
|
||||
*
|
||||
* @param string $source remove file
|
||||
* @param string $target local file
|
||||
* @return bool
|
||||
*/
|
||||
public function get($source, $target);
|
||||
|
||||
/**
|
||||
* Rename a remote file
|
||||
*
|
||||
* @param string $from
|
||||
* @param string $to
|
||||
* @return bool
|
||||
*/
|
||||
public function rename($from, $to);
|
||||
|
||||
/**
|
||||
* Get the name of the share
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName();
|
||||
|
||||
/**
|
||||
* Upload a local file
|
||||
*
|
||||
* @param string $source local file
|
||||
* @param string $target remove file
|
||||
* @return bool
|
||||
*/
|
||||
public function put($source, $target);
|
||||
|
||||
/**
|
||||
* @return Server
|
||||
*/
|
||||
public function getServer();
|
||||
|
||||
/**
|
||||
* List the content of a remote folder
|
||||
*
|
||||
* Returns a nested array in the format of
|
||||
* [
|
||||
* $name => [
|
||||
* 'size' => $size,
|
||||
* 'type' => $type,
|
||||
* 'time' => $mtime
|
||||
* ],
|
||||
* ...
|
||||
* ]
|
||||
*
|
||||
* @param $path
|
||||
* @return array[]
|
||||
*/
|
||||
public function dir($path);
|
||||
|
||||
/**
|
||||
* Remove a folder on the share
|
||||
*
|
||||
* @param string $path
|
||||
* @return bool
|
||||
*/
|
||||
public function rmdir($path);
|
||||
|
||||
/**
|
||||
* Delete a file on the share
|
||||
*
|
||||
* @param string $path
|
||||
* @return bool
|
||||
*/
|
||||
public function del($path);
|
||||
|
||||
/**
|
||||
* Open a readable stream top a remote file
|
||||
*
|
||||
* @param string $source
|
||||
* @return resource a read only stream with the contents of the remote file
|
||||
*/
|
||||
public function read($source);
|
||||
}
|
||||
|
|
@ -67,7 +67,7 @@ class Server {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return Share[]
|
||||
* @return \Icewind\SMB\IShare[]
|
||||
* @throws \Icewind\SMB\AuthenticationException
|
||||
* @throws \Icewind\SMB\InvalidHostException
|
||||
*/
|
||||
|
|
@ -118,7 +118,7 @@ class Server {
|
|||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return Share
|
||||
* @return \Icewind\SMB\IShare
|
||||
*/
|
||||
public function getShare($name) {
|
||||
return new Share($this, $name);
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
namespace Icewind\SMB;
|
||||
|
||||
class Share {
|
||||
class Share implements IShare {
|
||||
/**
|
||||
* @var Server $server
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue