You are here

function FileBase::verifyDirectory in Forena Reports 8

Same name and namespace in other branches
  1. 7.5 src/File/FileBase.php \Drupal\forena\File\FileBase::verifyDirectory()
1 call to FileBase::verifyDirectory()
FileBase::save in src/File/FileBaseOld.php
Save a file into the report directory.

File

src/File/FileBaseOld.php, line 320
FileSystemBase.inc File toolbox for manipulating files contained tn the report directory.

Class

FileBase

Namespace

Drupal\forena\File

Code

function verifyDirectory($fullpath, $recursive = FALSE) {
  static $path = '';
  $success = TRUE;
  if (!$recursive) {
    $path = $this->dir;
    if (!is_writable($path)) {
      drupal_set_message(t('Directory %s is not modifiable', array(
        '%s' => $path,
      )), 'error');
      return FALSE;
    }
  }
  @(list($dir, $file) = explode('/', $fullpath, 2));
  $path .= '/' . $dir;

  // Path
  if (!file_exists($path) && $file) {
    @mkdir($path);
    if (!is_writable($path)) {
      drupal_set_message(t('Error creating directory %path', array(
        '%path' => $path,
      )), 'error');
      return FALSE;
    }
  }

  // Recurse to next file.
  if ($file && strpos($file, '/')) {
    $this
      ->verifyDirectory($file, TRUE);
  }
  return TRUE;
}