resolved https://github.com/ManiaControl/ManiaControl/issues/22 (added isHiddenFile method)
This commit is contained in:
parent
653ee5b577
commit
01bc21e37b
@ -26,7 +26,7 @@ abstract class BackupUtil {
|
||||
}
|
||||
|
||||
$time = date('y-m-d_H-i-s');
|
||||
if(defined('PHP_UNIT_TEST')){
|
||||
if (defined('PHP_UNIT_TEST')) {
|
||||
$time = date('y-m-d_H-i');
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ abstract class BackupUtil {
|
||||
}
|
||||
$useBaseFileNames = !empty($baseFileNames);
|
||||
while (false !== ($file = readdir($folderHandle))) {
|
||||
if (substr($file, 0, 1) === '.') {
|
||||
if (FileUtil::isHiddenFile($file)) {
|
||||
// Skip such .files
|
||||
continue;
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ namespace ManiaControl\Files;
|
||||
|
||||
use ManiaControl\Logger;
|
||||
use ManiaControl\Utils\Formatter;
|
||||
use ManiaControl\Utils\SystemUtil;
|
||||
use ManiaControl\Utils\WebReader;
|
||||
|
||||
/**
|
||||
@ -131,7 +130,7 @@ abstract class FileUtil {
|
||||
foreach ($directories as $directory) {
|
||||
$dir = new \RecursiveDirectoryIterator(MANIACONTROL_PATH . $directory);
|
||||
foreach (new \RecursiveIteratorIterator($dir) as $fileName => $file) {
|
||||
if (substr($fileName, 0, 1) === '.') {
|
||||
if (self::isHiddenFile($fileName)) {
|
||||
continue;
|
||||
}
|
||||
if (!is_writable($fileName)) {
|
||||
@ -227,4 +226,14 @@ abstract class FileUtil {
|
||||
|
||||
return $className;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a File is Hidden
|
||||
*
|
||||
* @param $fileName
|
||||
* @return bool
|
||||
*/
|
||||
public static function isHiddenFile($fileName) {
|
||||
return (substr($fileName, 0, 1) === '.');
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ use FML\Controls\Quads\Quad_UIConstruction_Buttons;
|
||||
use FML\Controls\Quads\Quad_UIConstructionBullet_Buttons;
|
||||
use FML\ManiaLink;
|
||||
use FML\Script\Features\Paging;
|
||||
use ManiaControl\Files\FileUtil;
|
||||
use ManiaControl\Logger;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Manialinks\ManialinkManager;
|
||||
@ -246,7 +247,7 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
|
||||
$mapFiles = array();
|
||||
$dirFiles = scandir($directory);
|
||||
foreach ($dirFiles as $fileName) {
|
||||
if (substr($fileName, 0, 1) === '.') {
|
||||
if (FileUtil::isHiddenFile($fileName)) {
|
||||
continue;
|
||||
}
|
||||
$fullFileName = $directory . $fileName;
|
||||
|
@ -121,8 +121,8 @@ class PluginManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
$reflector = new ReflectionClass($pluginClass);
|
||||
$className = $pluginClass;
|
||||
$reflector = new ReflectionClass($pluginClass);
|
||||
$className = $pluginClass;
|
||||
$splitNameSpace = explode('\\', $pluginClass);
|
||||
if (is_array($splitNameSpace)) {
|
||||
$className = end($splitNameSpace);
|
||||
@ -297,7 +297,7 @@ class PluginManager {
|
||||
}
|
||||
$pluginFiles = scandir($directory);
|
||||
foreach ($pluginFiles as $pluginFile) {
|
||||
if (substr($pluginFile, 0, 1) === '.') {
|
||||
if (FileUtil::isHiddenFile($pluginFile)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
21
phpunittests/core/Utils/SystemUtilTest.php
Normal file
21
phpunittests/core/Utils/SystemUtilTest.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Lukas
|
||||
* Date: 16. Apr. 2017
|
||||
* Time: 15:38
|
||||
*/
|
||||
|
||||
use ManiaControl\Utils\SystemUtil;
|
||||
|
||||
class SystemUtilTest extends PHPUnit_Framework_TestCase {
|
||||
public function testCheckRequirements() {
|
||||
SystemUtil::checkRequirements();
|
||||
|
||||
$this->assertContains("Checking for minimum required PHP-Version 5.4", $this->getActualOutput());
|
||||
$this->assertContains("Checking for installed MySQLi ... FOUND!", $this->getActualOutput());
|
||||
$this->assertContains("Checking for installed cURL ... FOUND!", $this->getActualOutput());
|
||||
$this->assertContains("Checking for installed PHP ZIP ... FOUND!", $this->getActualOutput());
|
||||
$this->assertContains("Checking for installed Zlib ... FOUND!", $this->getActualOutput());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user