forked from appwrite/appwrite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDevice.php
More file actions
166 lines (149 loc) · 3.54 KB
/
Copy pathDevice.php
File metadata and controls
166 lines (149 loc) · 3.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<?php
namespace Appwrite\Storage;
use Exception;
abstract class Device
{
/**
* Get Name.
*
* Get storage device name
*
* @return string
*/
abstract public function getName():string;
/**
* Get Description.
*
* Get storage device description and purpose.
*
* @return string
*/
abstract public function getDescription():string;
/**
* Get Root.
*
* Get storage device root path
*
* @return string
*/
abstract public function getRoot():string;
/**
* Get Path.
*
* Each device hold a complex directory structure that is being build in this method.
*
* @param $filename
*
* @return string
*/
abstract public function getPath($filename):string;
/**
* Upload.
*
* Upload a file to desired destination in the selected disk, return true on success and false on failure.
*
* @param string $source
* @param string $path
*
* @throws \Exception
*
* @return bool
*/
abstract public function upload($source, $path):bool;
/**
* Read file by given path.
*
* @param string $path
*
* @return string
*/
abstract public function read(string $path):string;
/**
* Write file by given path.
*
* @param string $path
* @param string $data
*
* @return string
*/
abstract public function write(string $path, string $data):bool;
/**
* Move file from given source to given path, return true on success and false on failure.
*
* @see http://php.net/manual/en/function.filesize.php
*
* @param string $source
* @param string $target
*
* @return bool
*/
abstract public function move(string $source, string $target):bool;
/**
* Delete file in given path return true on success and false on failure.
*
* @see http://php.net/manual/en/function.filesize.php
*
* @param string $path
*
* @return bool
*/
abstract public function delete(string $path):bool;
/**
* Returns given file path its size.
*
* @see http://php.net/manual/en/function.filesize.php
*
* @param $path
*
* @return int
*/
abstract public function getFileSize(string $path):int;
/**
* Returns given file path its mime type.
*
* @see http://php.net/manual/en/function.mime-content-type.php
*
* @param $path
*
* @return string
*/
abstract public function getFileMimeType(string $path):string;
/**
* Returns given file path its MD5 hash value.
*
* @see http://php.net/manual/en/function.md5-file.php
*
* @param $path
*
* @return string
*/
abstract public function getFileHash(string $path):string;
/**
* Get directory size in bytes.
*
* Return -1 on error
*
* Based on http://www.jonasjohn.de/snippets/php/dir-size.htm
*
* @param $path
*
* @return int
*/
abstract public function getDirectorySize(string $path):int;
/**
* Get Partition Free Space.
*
* disk_free_space — Returns available space on filesystem or disk partition
*
* @return float
*/
abstract public function getPartitionFreeSpace():float;
/**
* Get Partition Total Space.
*
* disk_total_space — Returns the total size of a filesystem or disk partition
*
* @return float
*/
abstract public function getPartitionTotalSpace():float;
}