public static function fixPermissions($path, $recursive = FALSE) {
		if (TYPO3_OS != 'WIN') {
			$result = FALSE;

				// Make path absolute
			if (!self::isAbsPath($path)) {
				$path = self::getFileAbsFileName($path, FALSE);
			}

			if (self::isAllowedAbsPath($path)) {
				if (@is_file($path)) {
						// "@" is there because file is not necessarily OWNED by the user
					$result = @chmod($path, octdec($GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask']));
				} elseif (@is_dir($path)) {
						// "@" is there because file is not necessarily OWNED by the user
					$result = @chmod($path, octdec($GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask']));
				}

					// Set createGroup if not empty
				if ($GLOBALS['TYPO3_CONF_VARS']['BE']['createGroup']) {
						// "@" is there because file is not necessarily OWNED by the user
					$changeGroupResult = @chgrp($path, $GLOBALS['TYPO3_CONF_VARS']['BE']['createGroup']);
					$result = $changeGroupResult ? $result : FALSE;
				}

					// Call recursive if recursive flag if set and $path is directory
				if ($recursive && @is_dir($path)) {
					$handle = opendir($path);
					while (($file = readdir($handle)) !== FALSE) {
						$recursionResult = NULL;
						if ($file !== '.' && $file !== '..') {
							if (@is_file($path . '/' . $file)) {
								$recursionResult = self::fixPermissions($path . '/' . $file);
							} elseif (@is_dir($path . '/' . $file)) {
								$recursionResult = self::fixPermissions($path . '/' . $file, TRUE);
							}
							if (isset($recursionResult) && !$recursionResult) {
								$result = FALSE;
							}
						}
					}
					closedir($handle);
				}
			}
		} else {
			$result = TRUE;
		}
		return $result;
	}