| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
@copyright |
|---|
| 6 |
@author will@flourishlib.com |
|---|
| 7 |
@license http://flourishlib.com/license |
|---|
| 8 |
|
|---|
| 9 |
@package |
|---|
| 10 |
@link http://flourishlib.com/fFilesystem |
|---|
| 11 |
|
|---|
| 12 |
@version |
|---|
| 13 |
@changes |
|---|
| 14 |
|
|---|
| 15 |
class fFilesystem |
|---|
| 16 |
{ |
|---|
| 17 |
|
|---|
| 18 |
const addWebPathTranslation = 'fFilesystem::addWebPathTranslation'; |
|---|
| 19 |
const begin = 'fFilesystem::begin'; |
|---|
| 20 |
const commit = 'fFilesystem::commit'; |
|---|
| 21 |
const convertToBytes = 'fFilesystem::convertToBytes'; |
|---|
| 22 |
const formatFilesize = 'fFilesystem::formatFilesize'; |
|---|
| 23 |
const getPathInfo = 'fFilesystem::getPathInfo'; |
|---|
| 24 |
const hookExceptionMap = 'fFilesystem::hookExceptionMap'; |
|---|
| 25 |
const hookFilenameMap = 'fFilesystem::hookFilenameMap'; |
|---|
| 26 |
const isInsideTransaction = 'fFilesystem::isInsideTransaction'; |
|---|
| 27 |
const makeUniqueName = 'fFilesystem::makeUniqueName'; |
|---|
| 28 |
const recordCreate = 'fFilesystem::recordCreate'; |
|---|
| 29 |
const recordDelete = 'fFilesystem::recordDelete'; |
|---|
| 30 |
const recordDuplicate = 'fFilesystem::recordDuplicate'; |
|---|
| 31 |
const recordRename = 'fFilesystem::recordRename'; |
|---|
| 32 |
const recordWrite = 'fFilesystem::recordWrite'; |
|---|
| 33 |
const reset = 'fFilesystem::reset'; |
|---|
| 34 |
const rollback = 'fFilesystem::rollback'; |
|---|
| 35 |
const translateToWebPath = 'fFilesystem::translateToWebPath'; |
|---|
| 36 |
const updateExceptionMap = 'fFilesystem::updateExceptionMap'; |
|---|
| 37 |
const updateFilenameMap = 'fFilesystem::updateFilenameMap'; |
|---|
| 38 |
const updateFilenameMapForDirectory = 'fFilesystem::updateFilenameMapForDirectory'; |
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
@var |
|---|
| 45 |
|
|---|
| 46 |
static private $commit_operations = NULL; |
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
@var |
|---|
| 52 |
|
|---|
| 53 |
static private $exception_map = array(); |
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
@var |
|---|
| 59 |
|
|---|
| 60 |
static private $filename_map = array(); |
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 |
@var |
|---|
| 66 |
|
|---|
| 67 |
static private $rollback_operations = NULL; |
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 |
@var |
|---|
| 73 |
|
|---|
| 74 |
static private $web_path_translations = array(); |
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 |
@param |
|---|
| 88 |
@param |
|---|
| 89 |
@return |
|---|
| 90 |
|
|---|
| 91 |
static public function addWebPathTranslation($search_path, $replace_path) |
|---|
| 92 |
{ |
|---|
| 93 |
|
|---|
| 94 |
$search_path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $search_path); |
|---|
| 95 |
$replace_path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $replace_path); |
|---|
| 96 |
self::$web_path_translations[$search_path] = $replace_path; |
|---|
| 97 |
} |
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 |
|
|---|
| 101 |
|
|---|
| 102 |
|
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 |
|
|---|
| 109 |
|
|---|
| 110 |
@return |
|---|
| 111 |
|
|---|
| 112 |
static public function begin() |
|---|
| 113 |
{ |
|---|
| 114 |
if (self::$commit_operations !== NULL) { |
|---|
| 115 |
fCore::toss( |
|---|
| 116 |
'fProgrammerException', |
|---|
| 117 |
fGrammar::compose( |
|---|
| 118 |
'There is already a filesystem transaction in progress' |
|---|
| 119 |
) |
|---|
| 120 |
); |
|---|
| 121 |
} |
|---|
| 122 |
self::$commit_operations = array(); |
|---|
| 123 |
self::$rollback_operations = array(); |
|---|
| 124 |
} |
|---|
| 125 |
|
|---|
| 126 |
|
|---|
| 127 |
|
|---|
| 128 |
|
|---|
| 129 |
|
|---|
| 130 |
@return |
|---|
| 131 |
|
|---|
| 132 |
static public function commit() |
|---|
| 133 |
{ |
|---|
| 134 |
if (!self::isInsideTransaction()) { |
|---|
| 135 |
fCore::toss( |
|---|
| 136 |
'fProgrammerException', |
|---|
| 137 |
fGrammar::compose( |
|---|
| 138 |
'There is no filesystem transaction in progress to commit' |
|---|
| 139 |
) |
|---|
| 140 |
); |
|---|
| 141 |
} |
|---|
| 142 |
|
|---|
| 143 |
$commit_operations = self::$commit_operations; |
|---|
| 144 |
|
|---|
| 145 |
self::$commit_operations = NULL; |
|---|
| 146 |
self::$rollback_operations = NULL; |
|---|
| 147 |
|
|---|
| 148 |
$commit_operations = array_reverse($commit_operations); |
|---|
| 149 |
|
|---|
| 150 |
foreach ($commit_operations as $operation) { |
|---|
| 151 |
|
|---|
| 152 |
if (isset($operation['filename'])) { |
|---|
| 153 |
@unlink($operation['filename']); |
|---|
| 154 |
} else { |
|---|
| 155 |
$operation['object']->delete(); |
|---|
| 156 |
} |
|---|
| 157 |
} |
|---|
| 158 |
} |
|---|
| 159 |
|
|---|
| 160 |
|
|---|
| 161 |
|
|---|
| 162 |
|
|---|
| 163 |
|
|---|
| 164 |
@param |
|---|
| 165 |
@return |
|---|
| 166 |
|
|---|
| 167 |
static public function convertToBytes($size) |
|---|
| 168 |
{ |
|---|
| 169 |
if (!preg_match('#^(\d+)\s*(k|m|g|t)?(ilo|ega|era|iga)?( )?b?(yte(s)?)?$#', strtolower(trim($size)), $matches)) { |
|---|
| 170 |
fCore::toss( |
|---|
| 171 |
'fProgrammerException', |
|---|
| 172 |
fGrammar::compose( |
|---|
| 173 |
'The size specified, %s, does not appears to be a valid size', |
|---|
| 174 |
fCore::dump($size) |
|---|
| 175 |
) |
|---|
| 176 |
); |
|---|
| 177 |
} |
|---|
| 178 |
|
|---|
| 179 |
if ($matches[2] == '') { |
|---|
| 180 |
$matches[2] = 'b'; |
|---|
| 181 |
} |
|---|
| 182 |
|
|---|
| 183 |
$size_map = array('b' => 1, |
|---|
| 184 |
'k' => 1024, |
|---|
| 185 |
'm' => 1048576, |
|---|
| 186 |
'g' => 1073741824, |
|---|
| 187 |
't' => 1099511627776); |
|---|
| 188 |
return $matches[1] * $size_map[$matches[2]]; |
|---|
| 189 |
} |
|---|
| 190 |
|
|---|
| 191 |
|
|---|
| 192 |
|
|---|
| 193 |
|
|---|
| 194 |
|
|---|
| 195 |
@param |
|---|
| 196 |
@param |
|---|
| 197 |
@return |
|---|
| 198 |
|
|---|
| 199 |
static public function formatFilesize($bytes, $decimal_places=1) |
|---|
| 200 |
{ |
|---|
| 201 |
if ($bytes < 0) { |
|---|
| 202 |
$bytes = 0; |
|---|
| 203 |
} |
|---|
| 204 |
$suffixes = array('b', 'kb', 'mb', 'gb', 'tb'); |
|---|
| 205 |
$sizes = array(1, 1024, 1048576, 1073741824, 1099511627776); |
|---|
| 206 |
$suffix = floor(log($bytes)/6.9314718); |
|---|
| 207 |
return number_format($bytes/$sizes[$suffix], $decimal_places) . $suffixes[$suffix]; |
|---|
| 208 |
} |
|---|
| 209 |
|
|---|
| 210 |
|
|---|
| 211 |
|
|---|
| 212 |
|
|---|
| 213 |
|
|---|
| 214 |
@param |
|---|
| 215 |
@param |
|---|
| 216 |
@return |
|---|
| 217 |
|
|---|
| 218 |
static public function getPathInfo($file, $element=NULL) |
|---|
| 219 |
{ |
|---|
| 220 |
$valid_elements = array('dirname', 'basename', 'extension', 'filename'); |
|---|
| 221 |
if ($element !== NULL && !in_array($element, $valid_elements)) { |
|---|
| 222 |
fCore::toss( |
|---|
| 223 |
'fProgrammerException', |
|---|
| 224 |
fGrammar::compose( |
|---|
| 225 |
'The element specified, %1$s, is invalid. Must be one of: %2$s.', |
|---|
| 226 |
fCore::dump($element), |
|---|
| 227 |
join(', ', $valid_elements) |
|---|
| 228 |
) |
|---|
| 229 |
); |
|---|
| 230 |
} |
|---|
| 231 |
|
|---|
| 232 |
$path_info = pathinfo($file); |
|---|
| 233 |
|
|---|
| 234 |
if (!isset($path_info['extension'])) { |
|---|
| 235 |
$path_info['extension'] = NULL; |
|---|
| 236 |
} |
|---|
| 237 |
|
|---|
| 238 |
if (!isset($path_info['filename'])) { |
|---|
| 239 |
$path_info['filename'] = preg_replace('#\.' . preg_quote($path_info['extension'], '#') . '$#', '', $path_info['basename']); |
|---|
| 240 |
} |
|---|
| 241 |
$path_info['dirname'] .= DIRECTORY_SEPARATOR; |
|---|
| 242 |
|
|---|
| 243 |
if ($element) { |
|---|
| 244 |
return $path_info[$element]; |
|---|
| 245 |
} |
|---|
| 246 |
|
|---|
| 247 |
return $path_info; |
|---|
| 248 |
} |
|---|
| 249 |
|
|---|
| 250 |
|
|---|
| 251 |
|
|---|
| 252 |
|
|---|
| 253 |
|
|---|
| 254 |
|
|---|
| 255 |
|
|---|
| 256 |
|
|---|
| 257 |
@internal |
|---|
| 258 |
|
|---|
| 259 |
@param |
|---|
| 260 |
@return |
|---|
| 261 |
|
|---|
| 262 |
static public function &hookExceptionMap($file) |
|---|
| 263 |
{ |
|---|
| 264 |
if (!isset(self::$exception_map[$file])) { |
|---|
| 265 |
self::$exception_map[$file] = NULL; |
|---|
| 266 |
} |
|---|
| 267 |
return self::$exception_map[$file]; |
|---|
| 268 |
} |
|---|
| 269 |
|
|---|
| 270 |
|
|---|
| 271 |
|
|---|
| 272 |
|
|---|
| 273 |
|
|---|
| 274 |
|
|---|
| 275 |
|
|---|
| 276 |
|
|---|
| 277 |
@internal |
|---|
| 278 |
|
|---|
| 279 |
@param |
|---|
| 280 |
@return |
|---|
| 281 |
|
|---|
| 282 |
static public function &hookFilenameMap($file) |
|---|
| 283 |
{ |
|---|
| 284 |
if (!isset(self::$filename_map[$file])) { |
|---|
| 285 |
self::$filename_map[$file] = $file; |
|---|
| 286 |
} |
|---|
| 287 |
return self::$filename_map[$file]; |
|---|
| 288 |
} |
|---|
| 289 |
|
|---|
| 290 |
|
|---|
| 291 |
|
|---|
| 292 |
|
|---|
| 293 |
|
|---|
| 294 |
@return |
|---|
| 295 |
|
|---|
| 296 |
static public function isInsideTransaction() |
|---|
| 297 |
{ |
|---|
| 298 |
return is_array(self::$commit_operations); |
|---|
| 299 |
} |
|---|
| 300 |
|
|---|
| 301 |
|
|---|
| 302 |
|
|---|
| 303 |
|
|---|
| 304 |
|
|---|
| 305 |
@param |
|---|
| 306 |
@param |
|---|
| 307 |
@return |
|---|
| 308 |
|
|---|
| 309 |
static public function makeUniqueName($file, $new_extension=NULL) |
|---|
| 310 |
{ |
|---|
| 311 |
$info = self::getPathInfo($file); |
|---|
| 312 |
|
|---|
| 313 |
|
|---|
| 314 |
if ($new_extension !== NULL) { |
|---|
| 315 |
$new_extension = ($new_extension) ? '.' . $new_extension : $new_extension; |
|---|
| 316 |
$file = $info['dirname'] . $info['filename'] . $new_extension; |
|---|
| 317 |
$info = self::getPathInfo($file); |
|---|
| 318 |
} |
|---|
| 319 |
|
|---|
| 320 |
|
|---|
| 321 |
$extension = (!empty($info['extension'])) ? '.' . $info['extension'] : ''; |
|---|
| 322 |
|
|---|
| 323 |
|
|---|
| 324 |
$file = preg_replace('#_copy(\d+)' . preg_quote($extension, '#') . '$#', $extension, $file); |
|---|
| 325 |
|
|---|
| 326 |
|
|---|
| 327 |
while (file_exists($file)) { |
|---|
| 328 |
$info = self::getPathInfo($file); |
|---|
| 329 |
if (preg_match('#_copy(\d+)' . preg_quote($extension, '#') . '$#', $file, $match)) { |
|---|
| 330 |
$file = preg_replace('#_copy(\d+)' . preg_quote($extension, '#') . '$#', '_copy' . ($match[1]+1) . $extension, $file); |
|---|
| 331 |
} else { |
|---|
| 332 |
$file = $info['dirname'] . $info['filename'] . '_copy1' . $extension; |
|---|
| 333 |
} |
|---|
| 334 |
} |
|---|
| 335 |
|
|---|
| 336 |
return $file; |
|---|
| 337 |
} |
|---|
| 338 |
|
|---|
| 339 |
|
|---|
| 340 |
|
|---|
| 341 |
|
|---|
| 342 |
|
|---|
| 343 |
@internal |
|---|
| 344 |
|
|---|
| 345 |
@param |
|---|
| 346 |
@param |
|---|
| 347 |
@return |
|---|
| 348 |
|
|---|
| 349 |
static public function updateExceptionMap($file, Exception $exception) |
|---|
| 350 |
{ |
|---|
| 351 |
self::$exception_map[$file] = $exception; |
|---|
| 352 |
} |
|---|
| 353 |
|
|---|
| 354 |
|
|---|
| 355 |
|
|---|
| 356 |
|
|---|
| 357 |
|
|---|
| 358 |
@internal |
|---|
| 359 |
|
|---|
| 360 |
@param |
|---|
| 361 |
@param |
|---|
| 362 |
@return |
|---|
| 363 |
|
|---|
| 364 |
static public function updateFilenameMap($existing_filename, $new_filename) |
|---|
| 365 |
{ |
|---|
| 366 |
if ($existing_filename == $new_filename) { |
|---|
| 367 |
return; |
|---|
| 368 |
} |
|---|
| 369 |
|
|---|
| 370 |
self::$filename_map[$new_filename] =& self::$filename_map[$existing_filename]; |
|---|
| 371 |
self::$exception_map[$new_filename] =& self::$exception_map[$existing_filename]; |
|---|
| 372 |
|
|---|
| 373 |
unset(self::$filename_map[$existing_filename]); |
|---|
| 374 |
unset(self::$exception_map[$existing_filename]); |
|---|
| 375 |
|
|---|
| 376 |
self::$filename_map[$new_filename] = $new_filename; |
|---|
| 377 |
} |
|---|
| 378 |
|
|---|
| 379 |
|
|---|
| 380 |
|
|---|
| 381 |
|
|---|
| 382 |
|
|---|
| 383 |
|
|---|
| 384 |
|
|---|
| 385 |
@internal |
|---|
| 386 |
|
|---|
| 387 |
@param |
|---|
| 388 |
@param |
|---|
| 389 |
@return |
|---|
| 390 |
|
|---|
| 391 |
static public function updateFilenameMapForDirectory($existing_dirname, $new_dirname) |
|---|
| 392 |
{ |
|---|
| 393 |
if ($existing_dirname == $new_dirname) { |
|---|
| 394 |
return; |
|---|
| 395 |
} |
|---|
| 396 |
|
|---|
| 397 |
|
|---|
| 398 |
self::$filename_map[$new_dirname] =& self::$filename_map[$existing_dirname]; |
|---|
| 399 |
self::$exception_map[$new_dirname] =& self::$exception_map[$existing_dirname]; |
|---|
| 400 |
|
|---|
| 401 |
unset(self::$filename_map[$existing_dirname]); |
|---|
| 402 |
unset(self::$exception_map[$existing_dirname]); |
|---|
| 403 |
|
|---|
| 404 |
self::$filename_map[$new_dirname] = $new_dirname; |
|---|
| 405 |
|
|---|
| 406 |
|
|---|
| 407 |
foreach (self::$filename_map as $filename => $ignore) { |
|---|
| 408 |
if (preg_match('#^' . preg_quote($existing_dirname, '#') . '#', $filename)) { |
|---|
| 409 |
$new_filename = preg_replace('#^' . preg_quote($existing_dirname, '#') . '#', $new_dirname, $filename); |
|---|
| 410 |
|
|---|
| 411 |
self::$filename_map[$new_filename] =& self::$filename_map[$filename]; |
|---|
| 412 |
self::$exception_map[$new_filename] =& self::$exception_map[$filename]; |
|---|
| 413 |
|
|---|
| 414 |
unset(self::$filename_map[$filename]); |
|---|
| 415 |
unset(self::$exception_map[$filename]); |
|---|
| 416 |
|
|---|
| 417 |
self::$filename_map[$new_filename] = $new_filename; |
|---|
| 418 |
|
|---|
| 419 |
} |
|---|
| 420 |
} |
|---|
| 421 |
} |
|---|
| 422 |
|
|---|
| 423 |
|
|---|
| 424 |
|
|---|
| 425 |
|
|---|
| 426 |
|
|---|
| 427 |
@internal |
|---|
| 428 |
|
|---|
| 429 |
@param |
|---|
| 430 |
@return |
|---|
| 431 |
|
|---|
| 432 |
static public function recordCreate($object) |
|---|
| 433 |
{ |
|---|
| 434 |
self::$rollback_operations[] = array( |
|---|
| 435 |
'action' => 'delete', |
|---|
| 436 |
'object' => $object |
|---|
| 437 |
); |
|---|
| 438 |
} |
|---|
| 439 |
|
|---|
| 440 |
|
|---|
| 441 |
|
|---|
| 442 |
|
|---|
| 443 |
|
|---|
| 444 |
@internal |
|---|
| 445 |
|
|---|
| 446 |
@param |
|---|
| 447 |
@return |
|---|
| 448 |
|
|---|
| 449 |
static public function recordDelete($object) |
|---|
| 450 |
{ |
|---|
| 451 |
self::$commit_operations[] = array( |
|---|
| 452 |
'action' => 'delete', |
|---|
| 453 |
'object' => $object |
|---|
| 454 |
); |
|---|
| 455 |
} |
|---|
| 456 |
|
|---|
| 457 |
|
|---|
| 458 |
|
|---|
| 459 |
|
|---|
| 460 |
|
|---|
| 461 |
@internal |
|---|
| 462 |
|
|---|
| 463 |
@param |
|---|
| 464 |
@return |
|---|
| 465 |
|
|---|
| 466 |
static public function recordDuplicate(fFile $file) |
|---|
| 467 |
{ |
|---|
| 468 |
self::$rollback_operations[] = array( |
|---|
| 469 |
'action' => 'delete', |
|---|
| 470 |
'filename' => $file->getPath() |
|---|
| 471 |
); |
|---|
| 472 |
} |
|---|
| 473 |
|
|---|
| 474 |
|
|---|
| 475 |
|
|---|
| 476 |
|
|---|
| 477 |
|
|---|
| 478 |
@internal |
|---|
| 479 |
|
|---|
| 480 |
@param |
|---|
| 481 |
@param |
|---|
| 482 |
@return |
|---|
| 483 |
|
|---|
| 484 |
static public function recordRename($old_name, $new_name) |
|---|
| 485 |
{ |
|---|
| 486 |
self::$rollback_operations[] = array( |
|---|
| 487 |
'action' => 'rename', |
|---|
| 488 |
'old_name' => $old_name, |
|---|
| 489 |
'new_name' => $new_name |
|---|
| 490 |
); |
|---|
| 491 |
|
|---|
| 492 |
|
|---|
| 493 |
file_put_contents($old_name, ''); |
|---|
| 494 |
|
|---|
| 495 |
self::$commit_operations[] = array( |
|---|
| 496 |
'action' => 'delete', |
|---|
| 497 |
'filename' => $old_name |
|---|
| 498 |
); |
|---|
| 499 |
} |
|---|
| 500 |
|
|---|
| 501 |
|
|---|
| 502 |
|
|---|
| 503 |
|
|---|
| 504 |
|
|---|
| 505 |
@internal |
|---|
| 506 |
|
|---|
| 507 |
@param |
|---|
| 508 |
@return |
|---|
| 509 |
|
|---|
| 510 |
static public function recordWrite(fFile $file) |
|---|
| 511 |
{ |
|---|
| 512 |
self::$rollback_operations[] = array( |
|---|
| 513 |
'action' => 'write', |
|---|
| 514 |
'filename' => $file->getPath(), |
|---|
| 515 |
'old_data' => file_get_contents($file->getPath()) |
|---|
| 516 |
); |
|---|
| 517 |
} |
|---|
| 518 |
|
|---|
| 519 |
|
|---|
| 520 |
|
|---|
| 521 |
|
|---|
| 522 |
|
|---|
| 523 |
@internal |
|---|
| 524 |
|
|---|
| 525 |
@return |
|---|
| 526 |
|
|---|
| 527 |
static public function reset() |
|---|
| 528 |
{ |
|---|
| 529 |
self::rollback(); |
|---|
| 530 |
self::$exception_map = array(); |
|---|
| 531 |
self::$filename_map = array(); |
|---|
| 532 |
self::$web_path_translations = array(); |
|---|
| 533 |
} |
|---|
| 534 |
|
|---|
| 535 |
|
|---|
| 536 |
|
|---|
| 537 |
|
|---|
| 538 |
|
|---|
| 539 |
@return |
|---|
| 540 |
|
|---|
| 541 |
static public function rollback() |
|---|
| 542 |
{ |
|---|
| 543 |
self::$rollback_operations = array_reverse(self::$rollback_operations); |
|---|
| 544 |
|
|---|
| 545 |
foreach (self::$rollback_operations as $operation) { |
|---|
| 546 |
switch($operation['action']) { |
|---|
| 547 |
|
|---|
| 548 |
case 'delete': |
|---|
| 549 |
@unlink($operation['filename']); |
|---|
| 550 |
break; |
|---|
| 551 |
|
|---|
| 552 |
case 'write': |
|---|
| 553 |
file_put_contents($operation['filename'], $operation['old_data']); |
|---|
| 554 |
break; |
|---|
| 555 |
|
|---|
| 556 |
case 'rename': |
|---|
| 557 |
@rename($operation['new_name'], $operation['old_name']); |
|---|
| 558 |
break; |
|---|
| 559 |
|
|---|
| 560 |
} |
|---|
| 561 |
} |
|---|
| 562 |
|
|---|
| 563 |
|
|---|
| 564 |
foreach (self::$commit_operations as $operation) { |
|---|
| 565 |
if (isset($operation['object'])) { |
|---|
| 566 |
self::updateExceptionMap($operation['object']->getPath(), NULL); |
|---|
| 567 |
} |
|---|
| 568 |
} |
|---|
| 569 |
|
|---|
| 570 |
self::$commit_operations = NULL; |
|---|
| 571 |
self::$rollback_operations = NULL; |
|---|
| 572 |
} |
|---|
| 573 |
|
|---|
| 574 |
|
|---|
| 575 |
|
|---|
| 576 |
|
|---|
| 577 |
|
|---|
| 578 |
@param |
|---|
| 579 |
@return |
|---|
| 580 |
|
|---|
| 581 |
static public function translateToWebPath($path) |
|---|
| 582 |
{ |
|---|
| 583 |
$translations = array(realpath($_SERVER['DOCUMENT_ROOT']) => '') + self::$web_path_translations; |
|---|
| 584 |
|
|---|
| 585 |
foreach ($translations as $search => $replace) { |
|---|
| 586 |
$path = preg_replace('#^' . preg_quote($search, '#') . '#', $replace, $path); |
|---|
| 587 |
} |
|---|
| 588 |
|
|---|
| 589 |
return $path; |
|---|
| 590 |
} |
|---|
| 591 |
|
|---|
| 592 |
|
|---|
| 593 |
|
|---|
| 594 |
|
|---|
| 595 |
|
|---|
| 596 |
@return |
|---|
| 597 |
|
|---|
| 598 |
private function __construct() { } |
|---|
| 599 |
} |
|---|
| 600 |
|
|---|
| 601 |
|
|---|
| 602 |
|
|---|
| 603 |
|
|---|
| 604 |
will@flourishlib.com |
|---|
| 605 |
|
|---|
| 606 |
|
|---|
| 607 |
|
|---|
| 608 |
|
|---|
| 609 |
|
|---|
| 610 |
|
|---|
| 611 |
|
|---|
| 612 |
|
|---|
| 613 |
|
|---|
| 614 |
|
|---|
| 615 |
|
|---|
| 616 |
|
|---|
| 617 |
|
|---|
| 618 |
|
|---|
| 619 |
|
|---|
| 620 |
|
|---|
| 621 |
|
|---|
| 622 |
|
|---|
| 623 |
|
|---|