blob: 6d2fd5787338dee1349dbab6cde01ae4f730b21d [file] [log] [blame]
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +02001<?php
2
3namespace Illuminate\Contracts\Filesystem;
4
5interface Filesystem
6{
7 /**
8 * The public visibility setting.
9 *
10 * @var string
11 */
12 const VISIBILITY_PUBLIC = 'public';
13
14 /**
15 * The private visibility setting.
16 *
17 * @var string
18 */
19 const VISIBILITY_PRIVATE = 'private';
20
21 /**
22 * Determine if a file exists.
23 *
24 * @param string $path
25 * @return bool
26 */
27 public function exists($path);
28
29 /**
30 * Get the contents of a file.
31 *
32 * @param string $path
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +010033 * @return string|null
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020034 */
35 public function get($path);
36
37 /**
38 * Get a resource to read the file.
39 *
40 * @param string $path
41 * @return resource|null The path resource or null on failure.
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020042 */
43 public function readStream($path);
44
45 /**
46 * Write the contents of a file.
47 *
48 * @param string $path
49 * @param string|resource $contents
50 * @param mixed $options
51 * @return bool
52 */
53 public function put($path, $contents, $options = []);
54
55 /**
56 * Write a new file using a stream.
57 *
58 * @param string $path
59 * @param resource $resource
60 * @param array $options
61 * @return bool
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020062 */
63 public function writeStream($path, $resource, array $options = []);
64
65 /**
66 * Get the visibility for the given path.
67 *
68 * @param string $path
69 * @return string
70 */
71 public function getVisibility($path);
72
73 /**
74 * Set the visibility for the given path.
75 *
76 * @param string $path
77 * @param string $visibility
78 * @return bool
79 */
80 public function setVisibility($path, $visibility);
81
82 /**
83 * Prepend to a file.
84 *
85 * @param string $path
86 * @param string $data
87 * @return bool
88 */
89 public function prepend($path, $data);
90
91 /**
92 * Append to a file.
93 *
94 * @param string $path
95 * @param string $data
96 * @return bool
97 */
98 public function append($path, $data);
99
100 /**
101 * Delete the file at a given path.
102 *
103 * @param string|array $paths
104 * @return bool
105 */
106 public function delete($paths);
107
108 /**
109 * Copy a file to a new location.
110 *
111 * @param string $from
112 * @param string $to
113 * @return bool
114 */
115 public function copy($from, $to);
116
117 /**
118 * Move a file to a new location.
119 *
120 * @param string $from
121 * @param string $to
122 * @return bool
123 */
124 public function move($from, $to);
125
126 /**
127 * Get the file size of a given file.
128 *
129 * @param string $path
130 * @return int
131 */
132 public function size($path);
133
134 /**
135 * Get the file's last modification time.
136 *
137 * @param string $path
138 * @return int
139 */
140 public function lastModified($path);
141
142 /**
143 * Get an array of all files in a directory.
144 *
145 * @param string|null $directory
146 * @param bool $recursive
147 * @return array
148 */
149 public function files($directory = null, $recursive = false);
150
151 /**
152 * Get all of the files from the given directory (recursive).
153 *
154 * @param string|null $directory
155 * @return array
156 */
157 public function allFiles($directory = null);
158
159 /**
160 * Get all of the directories within a given directory.
161 *
162 * @param string|null $directory
163 * @param bool $recursive
164 * @return array
165 */
166 public function directories($directory = null, $recursive = false);
167
168 /**
169 * Get all (recursive) of the directories within a given directory.
170 *
171 * @param string|null $directory
172 * @return array
173 */
174 public function allDirectories($directory = null);
175
176 /**
177 * Create a directory.
178 *
179 * @param string $path
180 * @return bool
181 */
182 public function makeDirectory($path);
183
184 /**
185 * Recursively delete a directory.
186 *
187 * @param string $directory
188 * @return bool
189 */
190 public function deleteDirectory($directory);
191}