$aFileStats) { if (!self::CanWriteToFile($aFileStats)) { $sMessage = Dict::Format('FilesInformation:Error:CantWriteToFile', $sRootPath.DIRECTORY_SEPARATOR.$sFileName); return false; } if (($sFileName != '.') && ($aFileStats['type'] == 'dir')) { if (!self::CanWriteRecursive($sRootPath.DIRECTORY_SEPARATOR.$sFileName, $sMessage)) { return false; } } } return true; } /** * Check if iTop can write * @param string $sFilename absolute path to chack * * @return bool * @throws \Combodo\iTop\FilesInformation\Service\FileNotExistException */ public static function IsWritable($sFilename) { $aFileStats = FilesInformationUtils::GetFileStat(utils::LocalPath($sFilename)); return self::CanWriteToFile($aFileStats); } private static function CanWriteToFile($aFileStats) { if ($aFileStats['writable']) { return true; } if ($aFileStats['file_owner'] == self::$sItopOwner) { // If iTop owns the file, no pb to write return true; } return false; } /** * @throws \Combodo\iTop\FilesInformation\Service\FileNotExistException */ private static function Init() { clearstatcache(); $sSourceConfigFile = MetaModel::GetConfig()->GetLoadedFile(); $sSourceConfigFile = utils::LocalPath($sSourceConfigFile); $aConfigFiles = FilesInformationUtils::Scan(dirname($sSourceConfigFile)); if (!isset($aConfigFiles[basename($sSourceConfigFile)])) { return; } $aConfigStats = $aConfigFiles[basename($sSourceConfigFile)]; self::$sItopOwner = $aConfigStats['file_owner']; } public static function GetItopDiskSpace() { return FilesInformationUtils::GetDirSize(realpath(APPROOT)); } /** * @param $sLocalDirPath * * @return array * @throws \Combodo\iTop\FilesInformation\Service\FileNotExistException */ public static function GetDirInfo($sLocalDirPath) { if (utils::AbsolutePath($sLocalDirPath) === false) { return array(); } return FilesInformationUtils::Scan($sLocalDirPath); } }