mirror of
https://github.com/friendica/friendica
synced 2025-04-27 21:50:11 +00:00
move isDirectoryUsable to System
This commit is contained in:
parent
6a9d73f7d9
commit
b79bd63231
4 changed files with 47 additions and 49 deletions
|
@ -303,6 +303,44 @@ class System extends BaseObject
|
|||
return $processUser['name'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Checks if a given directory is usable for the system
|
||||
*
|
||||
* @param $directory
|
||||
* @param bool $check_writable
|
||||
*
|
||||
* @return boolean the directory is usable
|
||||
*/
|
||||
public static function isDirectoryUsable($directory, $check_writable = true)
|
||||
{
|
||||
if ($directory == '') {
|
||||
Logger::log('Directory is empty. This shouldn\'t happen.', Logger::DEBUG);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!file_exists($directory)) {
|
||||
Logger::log('Path "' . $directory . '" does not exist for user ' . static::getUser(), Logger::DEBUG);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_file($directory)) {
|
||||
Logger::log('Path "' . $directory . '" is a file for user ' . static::getUser(), Logger::DEBUG);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!is_dir($directory)) {
|
||||
Logger::log('Path "' . $directory . '" is not a directory for user ' . static::getUser(), Logger::DEBUG);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($check_writable && !is_writable($directory)) {
|
||||
Logger::log('Path "' . $directory . '" is not writable for user ' . static::getUser(), Logger::DEBUG);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// @todo Move the following functions from boot.php
|
||||
/*
|
||||
function killme()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue