You are here

public function ArchiveTar::_dirCheck in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Archiver/ArchiveTar.php \Drupal\Core\Archiver\ArchiveTar::_dirCheck()

Check if a directory exists and create it (including parent dirs) if not.

Parameters

string $p_dir directory to check:

Return value

bool true if the directory exists or was created

1 call to ArchiveTar::_dirCheck()
ArchiveTar::_extractList in core/lib/Drupal/Core/Archiver/ArchiveTar.php

File

core/lib/Drupal/Core/Archiver/ArchiveTar.php, line 2361

Class

ArchiveTar

Namespace

Drupal\Core\Archiver

Code

public function _dirCheck($p_dir) {
  clearstatcache();
  if (@is_dir($p_dir) || $p_dir == '') {
    return true;
  }
  $p_parent_dir = dirname($p_dir);
  if ($p_parent_dir != $p_dir && $p_parent_dir != '' && !$this
    ->_dirCheck($p_parent_dir)) {
    return false;
  }
  if (!@mkdir($p_dir, 0777)) {
    $this
      ->_error("Unable to create directory '{$p_dir}'");
    return false;
  }
  return true;
}