This example uses the permissions 0664 for files and 0775 for folders:
JPath::setPermissions($cleanPath, '0664', '0775');
The setPermissions() method returns a Boolean response. If the method fails to
update any of the permissions successfully false is returned.
Chapter 12
[ 347 ]
Before we use the setPermissions() method, we can use the canChmod() method
to ensure that we have the ability to modify the mode of a path:
if (JPath::canChmod($cleanPath))
{
JPath::setPermissions($cleanPath);
}
There is one last method that we will look at. The isOwner() method is used to
determine if the process user is the owner of a specific file:
if (JPath::isOwner($cleanPath))
{
// Process user is the owner
}
It is important to understand that the permissions-based methods
relate to the system user that is used to execute the script. They
do not relate to the Joomla! users.
Folders
We can handle folders using the static JFolder class. Before we explore how to use
JFolder we need to import the relevant library:
jimport('joomla.
Pages:
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482