1 <?php
2 /**
3 * @package Joomla.Platform
4 * @subpackage Filesystem
5 *
6 * @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
7 * @license GNU General Public License version 2 or later; see LICENSE
8 */
9
10 defined('JPATH_PLATFORM') or die;
11
12 jimport('joomla.filesystem.folder');
13
14 /**
15 * Wrapper class for JFilesystemFolder
16 *
17 * @package Joomla.Platform
18 * @subpackage Filesystem
19 * @since 3.4
20 */
21 class JFilesystemWrapperFolder
22 {
23 /**
24 * Helper wrapper method for copy
25 *
26 * @param string $src The path to the source folder.
27 * @param string $dest The path to the destination folder.
28 * @param string $path An optional base path to prefix to the file names.
29 * @param boolean $force Force copy.
30 * @param boolean $use_streams Optionally force folder/file overwrites.
31 *
32 * @return boolean True on success.
33 *
34 * @see JFolder::copy()
35 * @since 3.4
36 * @throws RuntimeException
37 */
38 public function copy($src, $dest, $path = '', $force = false, $use_streams = false)
39 {
40 return JFolder::copy($src, $dest, $path, $force, $use_streams);
41 }
42
43 /**
44 * Helper wrapper method for create
45 *
46 * @param string $path A path to create from the base path.
47 * @param integer $mode Directory permissions to set for folders created. 0755 by default.
48 *
49 * @return boolean True if successful.
50 *
51 * @see JFolder::create()
52 * @since 3.4
53 */
54 public function create($path = '', $mode = 493)
55 {
56 return JFolder::create($path, $mode);
57 }
58
59 /**
60 * Helper wrapper method for delete
61 *
62 * @param string $path The path to the folder to delete.
63 *
64 * @return boolean True on success.
65 *
66 * @see JFolder::delete()
67 * @since 3.4
68 * @throws UnexpectedValueException
69 */
70 public function delete($path)
71 {
72 return JFolder::delete($path);
73 }
74
75 /**
76 * Helper wrapper method for move
77 *
78 * @param string $src The path to the source folder.
79 * @param string $dest The path to the destination folder.
80 * @param string $path An optional base path to prefix to the file names.
81 * @param boolean $use_streams Optionally use streams.
82 *
83 * @return mixed Error message on false or boolean true on success.
84 *
85 * @see JFolder::move()
86 * @since 3.4
87 */
88 public function move($src, $dest, $path = '', $use_streams = false)
89 {
90 return JFolder::move($src, $dest, $path, $use_streams);
91 }
92
93 /**
94 * Helper wrapper method for exists
95 *
96 * @param string $path Folder name relative to installation dir.
97 *
98 * @return boolean True if path is a folder.
99 *
100 * @see JFolder::exists()
101 * @since 3.4
102 */
103 public function exists($path)
104 {
105 return JFolder::exists($path);
106 }
107
108 /**
109 * Helper wrapper method for files
110 *
111 * @param string $path The path of the folder to read.
112 * @param string $filter A filter for file names.
113 * @param mixed $recurse True to recursively search into sub-folders, or an integer to specify the maximum depth.
114 * @param boolean $full True to return the full path to the file.
115 * @param array $exclude Array with names of files which should not be shown in the result.
116 * @param array $excludefilter Array of filter to exclude.
117 * @param boolean $naturalSort False for asort, true for natsort.
118 *
119 * @return array Files in the given folder.
120 *
121 * @see JFolder::files()
122 * @since 3.4
123 */
124 public function files($path, $filter = '.', $recurse = false, $full = false, $exclude = array('.svn', 'CVS', '.DS_Store', '__MACOSX'),
125 $excludefilter = array('^\..*', '.*~'), $naturalSort = false)
126 {
127 return JFolder::files($path, $filter, $recurse, $full, $exclude, $excludefilter, $naturalSort);
128 }
129
130 /**
131 * Helper wrapper method for folders
132 *
133 * @param string $path The path of the folder to read.
134 * @param string $filter A filter for folder names.
135 * @param mixed $recurse True to recursively search into sub-folders, or an integer to specify the maximum depth.
136 * @param boolean $full True to return the full path to the folders.
137 * @param array $exclude Array with names of folders which should not be shown in the result.
138 * @param array $excludefilter Array with regular expressions matching folders which should not be shown in the result.
139 *
140 * @return array Folders in the given folder.
141 *
142 * @see JFolder::folders()
143 * @since 3.4
144 */
145 public function folders($path, $filter = '.', $recurse = false, $full = false, $exclude = array('.svn', 'CVS', '.DS_Store', '__MACOSX'),
146 $excludefilter = array('^\..*'))
147 {
148 return JFolder::folders($path, $filter, $recurse, $full, $exclude, $excludefilter);
149 }
150
151 /**
152 * Helper wrapper method for listFolderTree
153 *
154 * @param string $path The path of the folder to read.
155 * @param string $filter A filter for folder names.
156 * @param integer $maxLevel The maximum number of levels to recursively read, defaults to three.
157 * @param integer $level The current level, optional.
158 * @param integer $parent Unique identifier of the parent folder, if any.
159 *
160 * @return array Folders in the given folder.
161 *
162 * @see JFolder::listFolderTree()
163 * @since 3.4
164 */
165 public function listFolderTree($path, $filter, $maxLevel = 3, $level = 0, $parent = 0)
166 {
167 return JFolder::listFolderTree($path, $filter, $maxLevel, $level, $parent);
168 }
169
170 /**
171 * Helper wrapper method for makeSafe
172 *
173 * @param string $path The full path to sanitise.
174 *
175 * @return string The sanitised string
176 *
177 * @see JFolder::makeSafe()
178 * @since 3.4
179 */
180 public function makeSafe($path)
181 {
182 return JFolder::makeSafe($path);
183 }
184 }
185