|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Filesystem Adapter Interface |
| 4 | + * |
| 5 | + * @package Filesystem |
| 6 | + * @copyright 2013 Common Api. All rights reserved. |
| 7 | + * @license http://www.opensource.org/licenses/mit-license.html MIT License |
| 8 | + */ |
| 9 | +namespace Api\Filesystem; |
| 10 | + |
| 11 | +/** |
| 12 | + * Filesystem Adapter Interface |
| 13 | + * |
| 14 | + * @package Filesystem |
| 15 | + * @copyright 2013 Common Api. All rights reserved. |
| 16 | + * @license http://www.opensource.org/licenses/mit-license.html MIT License |
| 17 | + * @since 1.0 |
| 18 | + */ |
| 19 | +interface FilesystemInterface |
| 20 | +{ |
| 21 | + /** |
| 22 | + * Determines if file or folder identified in path exists |
| 23 | + * |
| 24 | + * @param string $path |
| 25 | + * |
| 26 | + * @return bool |
| 27 | + * @since 1.0 |
| 28 | + */ |
| 29 | + public function exists($path); |
| 30 | + |
| 31 | + /** |
| 32 | + * Returns an associative array of metadata for the file or folder specified in path |
| 33 | + * |
| 34 | + * @param string $path |
| 35 | + * |
| 36 | + * @return mixed |
| 37 | + * @since 1.0 |
| 38 | + */ |
| 39 | + public function getMetadata($path); |
| 40 | + |
| 41 | + /** |
| 42 | + * Returns the contents of the file identified in path |
| 43 | + * |
| 44 | + * @param string $path |
| 45 | + * |
| 46 | + * @return null|string |
| 47 | + * @since 1.0 |
| 48 | + */ |
| 49 | + public function read($path); |
| 50 | + |
| 51 | + /** |
| 52 | + * Returns a list of file and folder names located at path directory, optionally recursively, |
| 53 | + * optionally filtered by a list of file extension values, filename mask, and inclusion or exclusion |
| 54 | + * of files and/or folders |
| 55 | + * |
| 56 | + * @param string $path |
| 57 | + * @param bool $recursive |
| 58 | + * @param string $extension_list |
| 59 | + * @param bool $include_files |
| 60 | + * @param bool $include_folders |
| 61 | + * @param null $filename_mask |
| 62 | + * |
| 63 | + * @return mixed |
| 64 | + * @since 1.0 |
| 65 | + */ |
| 66 | + public function getList( |
| 67 | + $path, |
| 68 | + $recursive = false, |
| 69 | + $extension_list = '', |
| 70 | + $include_files = false, |
| 71 | + $include_folders = false, |
| 72 | + $filename_mask = null |
| 73 | + ); |
| 74 | + |
| 75 | + /** |
| 76 | + * Creates (or replaces) the file or creates the directory identified in path; |
| 77 | + * |
| 78 | + * @param string $path |
| 79 | + * @param string $data (file, only) |
| 80 | + * @param bool $replace (file, only) |
| 81 | + * @param bool $append (file, only) |
| 82 | + * @param bool $truncate (file, only) |
| 83 | + * |
| 84 | + * @return $this |
| 85 | + * @since 1.0 |
| 86 | + */ |
| 87 | + public function write($path, $data = '', $replace = true, $append = false, $truncate = false); |
| 88 | + |
| 89 | + /** |
| 90 | + * Deletes the file or folder identified in path, optionally deletes recursively |
| 91 | + * |
| 92 | + * @param string $path |
| 93 | + * @param bool $recursive |
| 94 | + * |
| 95 | + * @return $this |
| 96 | + * @since 1.0 |
| 97 | + */ |
| 98 | + public function delete($path, $recursive = false); |
| 99 | + |
| 100 | + /** |
| 101 | + * Copies the file/folder in $path to the target_directory (optionally target_name), |
| 102 | + * replacing content, if indicated. Can copy to target_handler. |
| 103 | + * |
| 104 | + * @param string $path |
| 105 | + * @param string $target_directory |
| 106 | + * @param string $target_name |
| 107 | + * @param bool $replace |
| 108 | + * @param string $target_handler |
| 109 | + * |
| 110 | + * @return $this |
| 111 | + * @since 1.0 |
| 112 | + */ |
| 113 | + public function copy( |
| 114 | + $path, |
| 115 | + $target_directory, |
| 116 | + $target_name = '', |
| 117 | + $replace = true, |
| 118 | + $target_handler = '' |
| 119 | + ); |
| 120 | + |
| 121 | + /** |
| 122 | + * Moves the file/folder in $path to the target_directory (optionally target_name), |
| 123 | + * replacing content, if indicated. Can move to target_handler. |
| 124 | + * |
| 125 | + * @param string $path |
| 126 | + * @param string $target_directory |
| 127 | + * @param string $target_name |
| 128 | + * @param bool $replace |
| 129 | + * @param string $target_handler |
| 130 | + * |
| 131 | + * @return $this |
| 132 | + * @since 1.0 |
| 133 | + */ |
| 134 | + public function move( |
| 135 | + $path, |
| 136 | + $target_directory, |
| 137 | + $target_name = '', |
| 138 | + $replace = true, |
| 139 | + $target_handler = '' |
| 140 | + ); |
| 141 | + |
| 142 | + /** |
| 143 | + * Rename file or folder identified in path |
| 144 | + * |
| 145 | + * @param string $path |
| 146 | + * @param string $new_name |
| 147 | + * |
| 148 | + * @return $this |
| 149 | + * @since 1.0 |
| 150 | + */ |
| 151 | + public function rename($path, $new_name); |
| 152 | + |
| 153 | + /** |
| 154 | + * Change owner for file or folder identified in path |
| 155 | + * |
| 156 | + * @param string $path |
| 157 | + * @param string $user_name |
| 158 | + * @param bool $recursive |
| 159 | + * |
| 160 | + * @return $this |
| 161 | + * @since 1.0 |
| 162 | + */ |
| 163 | + public function changeOwner($path, $user_name, $recursive = false); |
| 164 | + |
| 165 | + /** |
| 166 | + * Change group for file or folder identified in path |
| 167 | + * |
| 168 | + * @param string $path |
| 169 | + * @param string $group_id |
| 170 | + * @param bool $recursive |
| 171 | + * |
| 172 | + * @return $this |
| 173 | + * @since 1.0 |
| 174 | + */ |
| 175 | + public function changeGroup($path, $group_id, $recursive = false); |
| 176 | + |
| 177 | + /** |
| 178 | + * Change permissions for file or folder identified in path |
| 179 | + * |
| 180 | + * @param string $path |
| 181 | + * @param int $permission |
| 182 | + * @param bool $recursive |
| 183 | + * |
| 184 | + * @return $this |
| 185 | + * @since 1.0 |
| 186 | + */ |
| 187 | + public function changePermission($path, $permission, $recursive = false); |
| 188 | + |
| 189 | + /** |
| 190 | + * Update the modification time and access time (touch) for the directory or file identified in the path |
| 191 | + * |
| 192 | + * @param string $path |
| 193 | + * @param int $modification_time |
| 194 | + * @param int $access_time |
| 195 | + * @param bool $recursive |
| 196 | + * |
| 197 | + * @return $this |
| 198 | + * @since 1.0 |
| 199 | + */ |
| 200 | + public function touch($path, $modification_time = null, $access_time = null, $recursive = false); |
| 201 | +} |
0 commit comments