1111
1212namespace Symfony \Component \Filesystem ;
1313
14+ use Symfony \Component \Filesystem \Exception \IOException ;
15+
1416/**
1517 * Provides basic utility to manipulate the file system.
1618 *
@@ -29,7 +31,7 @@ class Filesystem
2931 * @param string $targetFile The target filename
3032 * @param array $override Whether to override an existing file or not
3133 *
32- * @throws Exception\ IOException When copy fails
34+ * @throws IOException When copy fails
3335 */
3436 public function copy ($ originFile , $ targetFile , $ override = false )
3537 {
@@ -43,7 +45,7 @@ public function copy($originFile, $targetFile, $override = false)
4345
4446 if ($ doCopy ) {
4547 if (true !== @copy ($ originFile , $ targetFile )) {
46- throw new Exception \ IOException (sprintf ('Failed to copy %s to %s ' , $ originFile , $ targetFile ));
48+ throw new IOException (sprintf ('Failed to copy %s to %s ' , $ originFile , $ targetFile ));
4749 }
4850 }
4951 }
@@ -54,7 +56,7 @@ public function copy($originFile, $targetFile, $override = false)
5456 * @param string|array|\Traversable $dirs The directory path
5557 * @param integer $mode The directory mode
5658 *
57- * @throws Exception\ IOException On any directory creation failure
59+ * @throws IOException On any directory creation failure
5860 */
5961 public function mkdir ($ dirs , $ mode = 0777 )
6062 {
@@ -64,7 +66,7 @@ public function mkdir($dirs, $mode = 0777)
6466 }
6567
6668 if (true !== @mkdir ($ dir , $ mode , true )) {
67- throw new Exception \ IOException (sprintf ('Failed to create %s ' , $ dir ));
69+ throw new IOException (sprintf ('Failed to create %s ' , $ dir ));
6870 }
6971 }
7072 }
@@ -94,7 +96,7 @@ public function exists($files)
9496 * @param integer $time The touch time as a unix timestamp
9597 * @param integer $atime The access time as a unix timestamp
9698 *
97- * @throws Exception\ IOException When touch fails
99+ * @throws IOException When touch fails
98100 */
99101 public function touch ($ files , $ time = null , $ atime = null )
100102 {
@@ -104,7 +106,7 @@ public function touch($files, $time = null, $atime = null)
104106
105107 foreach ($ this ->toIterator ($ files ) as $ file ) {
106108 if (true !== @touch ($ file , $ time , $ atime )) {
107- throw new Exception \ IOException (sprintf ('Failed to touch %s ' , $ file ));
109+ throw new IOException (sprintf ('Failed to touch %s ' , $ file ));
108110 }
109111 }
110112 }
@@ -114,7 +116,7 @@ public function touch($files, $time = null, $atime = null)
114116 *
115117 * @param string|array|\Traversable $files A filename, an array of files, or a \Traversable instance to remove
116118 *
117- * @throws Exception\ IOException When removal fails
119+ * @throws IOException When removal fails
118120 */
119121 public function remove ($ files )
120122 {
@@ -129,17 +131,17 @@ public function remove($files)
129131 $ this ->remove (new \FilesystemIterator ($ file ));
130132
131133 if (true !== @rmdir ($ file )) {
132- throw new Exception \ IOException (sprintf ('Failed to remove directory %s ' , $ file ));
134+ throw new IOException (sprintf ('Failed to remove directory %s ' , $ file ));
133135 }
134136 } else {
135137 // https://bugs.php.net/bug.php?id=52176
136138 if (defined ('PHP_WINDOWS_VERSION_MAJOR ' ) && is_dir ($ file )) {
137139 if (true !== @rmdir ($ file )) {
138- throw new Exception \ IOException (sprintf ('Failed to remove file %s ' , $ file ));
140+ throw new IOException (sprintf ('Failed to remove file %s ' , $ file ));
139141 }
140142 } else {
141143 if (true !== @unlink ($ file )) {
142- throw new Exception \ IOException (sprintf ('Failed to remove file %s ' , $ file ));
144+ throw new IOException (sprintf ('Failed to remove file %s ' , $ file ));
143145 }
144146 }
145147 }
@@ -154,7 +156,7 @@ public function remove($files)
154156 * @param integer $umask The mode mask (octal)
155157 * @param Boolean $recursive Whether change the mod recursively or not
156158 *
157- * @throws Exception\ IOException When the change fail
159+ * @throws IOException When the change fail
158160 */
159161 public function chmod ($ files , $ mode , $ umask = 0000 , $ recursive = false )
160162 {
@@ -163,7 +165,7 @@ public function chmod($files, $mode, $umask = 0000, $recursive = false)
163165 $ this ->chmod (new \FilesystemIterator ($ file ), $ mode , $ umask , true );
164166 }
165167 if (true !== @chmod ($ file , $ mode & ~$ umask )) {
166- throw new Exception \ IOException (sprintf ('Failed to chmod file %s ' , $ file ));
168+ throw new IOException (sprintf ('Failed to chmod file %s ' , $ file ));
167169 }
168170 }
169171 }
@@ -175,7 +177,7 @@ public function chmod($files, $mode, $umask = 0000, $recursive = false)
175177 * @param string $user The new owner user name
176178 * @param Boolean $recursive Whether change the owner recursively or not
177179 *
178- * @throws Exception\ IOException When the change fail
180+ * @throws IOException When the change fail
179181 */
180182 public function chown ($ files , $ user , $ recursive = false )
181183 {
@@ -185,11 +187,11 @@ public function chown($files, $user, $recursive = false)
185187 }
186188 if (is_link ($ file ) && function_exists ('lchown ' )) {
187189 if (true !== @lchown ($ file , $ user )) {
188- throw new Exception \ IOException (sprintf ('Failed to chown file %s ' , $ file ));
190+ throw new IOException (sprintf ('Failed to chown file %s ' , $ file ));
189191 }
190192 } else {
191193 if (true !== @chown ($ file , $ user )) {
192- throw new Exception \ IOException (sprintf ('Failed to chown file %s ' , $ file ));
194+ throw new IOException (sprintf ('Failed to chown file %s ' , $ file ));
193195 }
194196 }
195197 }
@@ -202,7 +204,7 @@ public function chown($files, $user, $recursive = false)
202204 * @param string $group The group name
203205 * @param Boolean $recursive Whether change the group recursively or not
204206 *
205- * @throws Exception\ IOException When the change fail
207+ * @throws IOException When the change fail
206208 */
207209 public function chgrp ($ files , $ group , $ recursive = false )
208210 {
@@ -212,11 +214,11 @@ public function chgrp($files, $group, $recursive = false)
212214 }
213215 if (is_link ($ file ) && function_exists ('lchgrp ' )) {
214216 if (true !== @lchgrp ($ file , $ group )) {
215- throw new Exception \ IOException (sprintf ('Failed to chgrp file %s ' , $ file ));
217+ throw new IOException (sprintf ('Failed to chgrp file %s ' , $ file ));
216218 }
217219 } else {
218220 if (true !== @chgrp ($ file , $ group )) {
219- throw new Exception \ IOException (sprintf ('Failed to chgrp file %s ' , $ file ));
221+ throw new IOException (sprintf ('Failed to chgrp file %s ' , $ file ));
220222 }
221223 }
222224 }
@@ -228,18 +230,18 @@ public function chgrp($files, $group, $recursive = false)
228230 * @param string $origin The origin filename
229231 * @param string $target The new filename
230232 *
231- * @throws Exception\ IOException When target file already exists
232- * @throws Exception\ IOException When origin cannot be renamed
233+ * @throws IOException When target file already exists
234+ * @throws IOException When origin cannot be renamed
233235 */
234236 public function rename ($ origin , $ target )
235237 {
236238 // we check that target does not exist
237239 if (is_readable ($ target )) {
238- throw new Exception \ IOException (sprintf ('Cannot rename because the target "%s" already exist. ' , $ target ));
240+ throw new IOException (sprintf ('Cannot rename because the target "%s" already exist. ' , $ target ));
239241 }
240242
241243 if (true !== @rename ($ origin , $ target )) {
242- throw new Exception \ IOException (sprintf ('Cannot rename "%s" to "%s". ' , $ origin , $ target ));
244+ throw new IOException (sprintf ('Cannot rename "%s" to "%s". ' , $ origin , $ target ));
243245 }
244246 }
245247
@@ -250,7 +252,7 @@ public function rename($origin, $target)
250252 * @param string $targetDir The symbolic link name
251253 * @param Boolean $copyOnWindows Whether to copy files if on Windows
252254 *
253- * @throws Exception\ IOException When symlink fails
255+ * @throws IOException When symlink fails
254256 */
255257 public function symlink ($ originDir , $ targetDir , $ copyOnWindows = false )
256258 {
@@ -273,7 +275,7 @@ public function symlink($originDir, $targetDir, $copyOnWindows = false)
273275
274276 if (!$ ok ) {
275277 if (true !== @symlink ($ originDir , $ targetDir )) {
276- throw new Exception \ IOException (sprintf ('Failed to create symbolic link from %s to %s ' , $ originDir , $ targetDir ));
278+ throw new IOException (sprintf ('Failed to create symbolic link from %s to %s ' , $ originDir , $ targetDir ));
277279 }
278280 }
279281 }
@@ -322,7 +324,7 @@ public function makePathRelative($endPath, $startPath)
322324 * - $options['override'] Whether to override an existing file on copy or not (see copy())
323325 * - $options['copy_on_windows'] Whether to copy files instead of links on Windows (see symlink())
324326 *
325- * @throws Exception\ IOException When file type is unknown
327+ * @throws IOException When file type is unknown
326328 */
327329 public function mirror ($ originDir , $ targetDir , \Traversable $ iterator = null , $ options = array ())
328330 {
@@ -349,7 +351,7 @@ public function mirror($originDir, $targetDir, \Traversable $iterator = null, $o
349351 } elseif (is_file ($ file ) || ($ copyOnWindows && is_link ($ file ))) {
350352 $ this ->copy ($ file , $ target , isset ($ options ['override ' ]) ? $ options ['override ' ] : false );
351353 } else {
352- throw new Exception \ IOException (sprintf ('Unable to guess "%s" file type. ' , $ file ));
354+ throw new IOException (sprintf ('Unable to guess "%s" file type. ' , $ file ));
353355 }
354356 }
355357 }
0 commit comments