| Home |
|
» Kategorien
» Seiten » Suche |
« TYPO3 4.5, t3mootools and JSMin Firefox 4 ist langsam und hakt beim Scrollen »
PHP: making a file executableThe following little code snippet shows you how to change a files permissions to allow its owning user and group to read and execute it. public function makeExecutable() {
if(file_exists($this->executablePath)) {
if(DIRECTORY_SEPARATOR == '/') {
// add executable (1) and read (4) bits for user and group
$filePermissions = decoct(fileperms($this->executablePath));
$filePermissions = substr($filePermissions, strlen($filePermissions) - 3);
$newFilePermissions = $filePermissions[0] | 5;
$newFilePermissions .= $filePermissions[1] | 5;
$newFilePermissions .= $filePermissions[2];
if($newFilePermissions != $filePermissions) {
return chmod($this->executablePath, octdec($newFilePermissions));
}
}
}
return false;
}
Donnerstag, Februar 24th, 2011 and is filed under PHP. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site. Leave a Reply
© 2007 - 2009 Thorsten Boock
nerdcenter is proudly powered by
WordPress
Entries (RSS) and Comments (RSS). Calella | Lloret de Mar Reisen | Stalker Clear Sky | Empire Total War |
» Archiv
|