SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 471 | Next

James Kennard

"Mastering Joomla! 1.5 Extension and Framework Development"

filesystem.folder');
The JFolder class has a makeSafe() method that works in much the same way as
the JFile makeSafe() method. The JFolder version of this method removes unsafe
characters from a folder path. This example cleans the $folder path:
$folder = JPATH_COMPONENT.DS.'Foo&Bar';
$cleanFolder = JFolder::makeSafe($path);
The resultant value of $cleanFolder will be the same as $folder except the
ampersand will have been removed because it is deemed an unsafe character.
JFolder contains a number of common file-system commands. We are provided
with five methods that deal explicitly with folder management. The first of these is
the exists() method. This method is used to check if a folder exists and returns a
Boolean value:
if (!JFolder::exists($cleanFolder))
{
// handle folder does not exist
}
Utilities and Useful Classes
[ 348 ]
We can use the following methods to manage a folder: copy(), move(), delete(),
and create(). It's better to use these methods than to use the normal PHP file
management functions because, if FTP is enabled, these methods will attempt to use
an FTP connection.


Pages:
459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483