This repository was archived by the owner on Sep 10, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -284,6 +284,10 @@ public static function formatAppName($app_name)
284
284
*/
285
285
public static function recursiveRemoveDirectory ($ directorypath )
286
286
{
287
+ if (empty ($ directorypath ) || !is_dir ($ directorypath ))
288
+ {
289
+ return false ;
290
+ }
287
291
// if the path has a slash at the end, remove it here
288
292
$ directorypath = rtrim ($ directorypath , '/ ' );
289
293
// open the directory
@@ -324,5 +328,4 @@ public static function recursiveRemoveDirectory($directorypath)
324
328
return true ;
325
329
}
326
330
327
-
328
331
}
Original file line number Diff line number Diff line change @@ -156,6 +156,10 @@ public function testPrepareExecCommand()
156
156
/** tests recursiveRemoveDirectory function */
157
157
public function testRecursiveRemoveDirectory ()
158
158
{
159
+ // test some basic exception handling
160
+ $ this ->assertFalse (KWUtils::recursiveRemoveDirectory ('' ));
161
+ $ this ->assertFalse (KWUtils::recursiveRemoveDirectory ('thisstringisunlikelytobeadirectory ' ));
162
+
159
163
// create a two-level directory
160
164
$ testParentDir = $ this ->getTempDirectory () . '/KWUtilsParentDir ' ;
161
165
mkdir ($ testParentDir );
You can’t perform that action at this time.
0 commit comments