Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 36 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| helpers_VersionedFile | |
0.00% |
0 / 36 |
|
0.00% |
0 / 3 |
462 | |
0.00% |
0 / 1 |
| deleteFiles | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| rmWorkingCopy | |
0.00% |
0 / 14 |
|
0.00% |
0 / 1 |
56 | |||
| cpWorkingCopy | |
0.00% |
0 / 19 |
|
0.00% |
0 / 1 |
182 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; under version 2 |
| 7 | * of the License (non-upgradable). |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | * |
| 18 | * Copyright (c) 2002-2008 (original work) Public Research Centre Henri Tudor & University of Luxembourg |
| 19 | * (under the project TAO & TAO2); |
| 20 | * 2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung |
| 21 | * (under the project TAO-TRANSFER); |
| 22 | * 2009-2012 (update and modification) Public Research Centre Henri Tudor |
| 23 | * (under the project TAO-SUSTAIN & TAO-DEV); |
| 24 | * |
| 25 | */ |
| 26 | |
| 27 | /** |
| 28 | * Short description of class helpers_VersionedFile |
| 29 | * |
| 30 | * @access public |
| 31 | * @author Somsack Sipasseuth, <somsack.sipasseuth@tudor.lu> |
| 32 | * @package helpers |
| 33 | */ |
| 34 | class helpers_VersionedFile |
| 35 | { |
| 36 | // --- ASSOCIATIONS --- |
| 37 | |
| 38 | |
| 39 | // --- ATTRIBUTES --- |
| 40 | |
| 41 | // --- OPERATIONS --- |
| 42 | |
| 43 | /** |
| 44 | * Short description of method deleteFiles |
| 45 | * |
| 46 | * @access public |
| 47 | * @author Somsack Sipasseuth, <somsack.sipasseuth@tudor.lu> |
| 48 | * @param array files |
| 49 | * @return boolean |
| 50 | */ |
| 51 | public static function deleteFiles($files = []) |
| 52 | { |
| 53 | $returnValue = (bool) false; |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | return (bool) $returnValue; |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Short description of method rmWorkingCopy |
| 63 | * |
| 64 | * @access public |
| 65 | * @author Somsack Sipasseuth, <somsack.sipasseuth@tudor.lu> |
| 66 | * @param string path |
| 67 | * @param boolean recursive |
| 68 | * @return boolean |
| 69 | */ |
| 70 | public static function rmWorkingCopy($path, $recursive = true) |
| 71 | { |
| 72 | $returnValue = (bool) false; |
| 73 | |
| 74 | |
| 75 | |
| 76 | if (is_file($path)) { |
| 77 | if (preg_match('/^\//', $path)) { |
| 78 | $returnValue = @unlink($path); |
| 79 | } |
| 80 | } elseif ($recursive) { |
| 81 | if (is_dir($path)) { |
| 82 | $iterator = new DirectoryIterator($path); |
| 83 | foreach ($iterator as $fileinfo) { |
| 84 | if (!$fileinfo->isDot()) { |
| 85 | self::rmWorkingCopy($fileinfo->getPathname(), true); |
| 86 | } |
| 87 | unset($fileinfo); |
| 88 | } |
| 89 | unset($iterator); |
| 90 | $returnValue = @rmdir($path); |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | |
| 95 | |
| 96 | return (bool) $returnValue; |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * Short description of method cpWorkingCopy |
| 101 | * |
| 102 | * @access public |
| 103 | * @author Somsack Sipasseuth, <somsack.sipasseuth@tudor.lu> |
| 104 | * @param string source |
| 105 | * @param string destination |
| 106 | * @param boolean recursive |
| 107 | * @param boolean ignoreSystemFiles |
| 108 | * @return boolean |
| 109 | */ |
| 110 | public static function cpWorkingCopy($source, $destination, $recursive = true, $ignoreSystemFiles = true) |
| 111 | { |
| 112 | $returnValue = (bool) false; |
| 113 | |
| 114 | |
| 115 | |
| 116 | if (file_exists($source)) { |
| 117 | if (is_dir($source) && $recursive) { |
| 118 | foreach (scandir($source) as $file) { |
| 119 | if ($file != '.' && $file != '..' && $file != '.svn') { |
| 120 | if (!$ignoreSystemFiles && $file[0] == '.') { |
| 121 | continue; |
| 122 | } else { |
| 123 | self::cpWorkingCopy( |
| 124 | $source . '/' . $file, |
| 125 | $destination . '/' . $file, |
| 126 | true, |
| 127 | $ignoreSystemFiles |
| 128 | ); |
| 129 | } |
| 130 | } |
| 131 | } |
| 132 | } else { |
| 133 | if (is_dir(dirname($destination))) { |
| 134 | $returnValue = copy($source, $destination); |
| 135 | } elseif ($recursive) { |
| 136 | if (mkdir(dirname($destination), 0775, true)) { |
| 137 | $returnValue = self::cpWorkingCopy($source, $destination, false, $ignoreSystemFiles); |
| 138 | } |
| 139 | } |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | |
| 144 | |
| 145 | return (bool) $returnValue; |
| 146 | } |
| 147 | } |