TrackManiaControl/application/core/FileUtil.php

41 lines
900 B
PHP
Raw Normal View History

<?php
namespace ManiaControl;
/**
* File utility class
*
* @author steeffeen & kremsy
*/
2013-11-27 02:42:39 +01:00
abstract class FileUtil {
/**
* Load config xml-file
*
* @param string $fileName
* @return \SimpleXMLElement
*/
public static function loadConfig($fileName) {
$fileLocation = ManiaControlDir . '/configs/' . $fileName;
if (!file_exists($fileLocation)) {
trigger_error("Config file doesn't exist! ({$fileName})");
return null;
}
if (!is_readable($fileLocation)) {
trigger_error("Config file isn't readable! ({$fileName})");
return null;
}
return simplexml_load_file($fileLocation);
}
2013-11-27 02:42:39 +01:00
/**
* Return file name cleared from special characters
*
* @param string $fileName
* @return string
*/
public static function getClearedFileName($fileName) {
return str_replace(array('\\', '/', ':', '*', '?', '"', '<', '>', '|'), '_', $fileName);
}
}