You are here

function _forena_verify_directory in Forena Reports 7.4

Same name and namespace in other branches
  1. 8 forena.module \_forena_verify_directory()
  2. 6.2 forena.admin.inc \_forena_verify_directory()
  3. 6 forena.admin.inc \_forena_verify_directory()
  4. 7.5 forena.module \_forena_verify_directory()
  5. 7 forena.admin.inc \_forena_verify_directory()
  6. 7.2 forena.admin.inc \_forena_verify_directory()
  7. 7.3 forena.module \_forena_verify_directory()

Make sure a drectory exists in the report path prior to save.

Parameters

$fullpath Full path to the drectory to be copied:

$recursive Whether we are in a recursive call.:

1 call to _forena_verify_directory()
forena_save_report in ./forena.common.inc
Save the report file to disk

File

./forena.module, line 1577

Code

function _forena_verify_directory($fullpath, $recursive = FALSE) {
  static $path = '';
  $success = TRUE;
  if (!$recursive) {
    $path = forena_report_path();
    if (!is_writable($path)) {
      drupal_set_message(t('Report directory %s is not modifiable', array(
        '%s' => $path,
      )), 'error', FALSE);
      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, '/')) {
    _forena_verify_directory($file, TRUE);
  }
  return TRUE;
}