function Archive_Tar::_dirCheck

7.x system.tar.inc Archive_Tar::_dirCheck($p_dir)

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 Archive_Tar::_dirCheck()
Archive_Tar::_extractList in drupal-7.x/modules/system/system.tar.inc

File

drupal-7.x/modules/system/system.tar.inc, line 1798

Class

Archive_Tar
Creates a (compressed) Tar archive *

Code

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;
  }

  // Drupal integration.
  // Changed the code to use drupal_mkdir() instead of mkdir().
  if (!@drupal_mkdir($p_dir, 0777)) {
    $this->_error("Unable to create directory '$p_dir'");
    return false;
  }

  return true;
}