1 <?php
2 /**
3 * @package FrameworkOnFramework
4 * @subpackage platformFilesystem
5 * @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
6 * @license GNU General Public License version 2 or later; see LICENSE.txt
7 */
8
9 // Protect from unauthorized access
10 defined('FOF_INCLUDED') or die;
11
12 interface FOFPlatformFilesystemInterface
13 {
14 /**
15 * Does the file exists?
16 *
17 * @param $path string Path to the file to test
18 *
19 * @return bool
20 */
21 public function fileExists($path);
22
23 /**
24 * Delete a file or array of files
25 *
26 * @param mixed $file The file name or an array of file names
27 *
28 * @return boolean True on success
29 *
30 */
31 public function fileDelete($file);
32
33 /**
34 * Copies a file
35 *
36 * @param string $src The path to the source file
37 * @param string $dest The path to the destination file
38 *
39 * @return boolean True on success
40 */
41 public function fileCopy($src, $dest);
42
43 /**
44 * Write contents to a file
45 *
46 * @param string $file The full file path
47 * @param string &$buffer The buffer to write
48 *
49 * @return boolean True on success
50 */
51 public function fileWrite($file, &$buffer);
52
53 /**
54 * Checks for snooping outside of the file system root.
55 *
56 * @param string $path A file system path to check.
57 *
58 * @return string A cleaned version of the path or exit on error.
59 *
60 * @throws Exception
61 */
62 public function pathCheck($path);
63
64 /**
65 * Function to strip additional / or \ in a path name.
66 *
67 * @param string $path The path to clean.
68 * @param string $ds Directory separator (optional).
69 *
70 * @return string The cleaned path.
71 *
72 * @throws UnexpectedValueException
73 */
74 public function pathClean($path, $ds = DIRECTORY_SEPARATOR);
75
76 /**
77 * Searches the directory paths for a given file.
78 *
79 * @param mixed $paths An path string or array of path strings to search in
80 * @param string $file The file name to look for.
81 *
82 * @return mixed The full path and file name for the target file, or boolean false if the file is not found in any of the paths.
83 */
84 public function pathFind($paths, $file);
85
86 /**
87 * Wrapper for the standard file_exists function
88 *
89 * @param string $path Folder name relative to installation dir
90 *
91 * @return boolean True if path is a folder
92 */
93 public function folderExists($path);
94
95 /**
96 * Utility function to read the files in a folder.
97 *
98 * @param string $path The path of the folder to read.
99 * @param string $filter A filter for file names.
100 * @param mixed $recurse True to recursively search into sub-folders, or an integer to specify the maximum depth.
101 * @param boolean $full True to return the full path to the file.
102 * @param array $exclude Array with names of files which should not be shown in the result.
103 * @param array $excludefilter Array of filter to exclude
104 *
105 * @return array Files in the given folder.
106 */
107 public function folderFiles($path, $filter = '.', $recurse = false, $full = false, $exclude = array('.svn', 'CVS', '.DS_Store', '__MACOSX'),
108 $excludefilter = array('^\..*', '.*~'));
109
110 /**
111 * Utility function to read the folders in a folder.
112 *
113 * @param string $path The path of the folder to read.
114 * @param string $filter A filter for folder names.
115 * @param mixed $recurse True to recursively search into sub-folders, or an integer to specify the maximum depth.
116 * @param boolean $full True to return the full path to the folders.
117 * @param array $exclude Array with names of folders which should not be shown in the result.
118 * @param array $excludefilter Array with regular expressions matching folders which should not be shown in the result.
119 *
120 * @return array Folders in the given folder.
121 */
122 public function folderFolders($path, $filter = '.', $recurse = false, $full = false, $exclude = array('.svn', 'CVS', '.DS_Store', '__MACOSX'),
123 $excludefilter = array('^\..*'));
124
125 /**
126 * Create a folder -- and all necessary parent folders.
127 *
128 * @param string $path A path to create from the base path.
129 * @param integer $mode Directory permissions to set for folders created. 0755 by default.
130 *
131 * @return boolean True if successful.
132 */
133 public function folderCreate($path = '', $mode = 0755);
134 }