You are here

function module_builder_create_directory in Module Builder 6.2

Same name in this branch
  1. 6.2 includes/common_version_7.inc \module_builder_create_directory()
  2. 6.2 includes/common_version.inc \module_builder_create_directory()
Same name and namespace in other branches
  1. 7 includes/common_version_7.inc \module_builder_create_directory()
  2. 7 includes/common_version.inc \module_builder_create_directory()

Run through Drupal's directory creation and checking stuff, adding a version subfolder for common directories.

Parameters

$directory: A directory path. Should be either absolute or relative; the latter will be taken to mean it's inside the Drupal /files directory.

$common: Boolean to indicate whether this directory is common across several Drupal installations. If set, the actual directory used will be a subdirectory with a version number: eg path/to/dir/6

1 call to module_builder_create_directory()
_module_builder_get_hooks_directory in includes/common.inc
Get a directory to save or read hook data files.

File

includes/common_version_7.inc, line 21
common_version_7.inc Stuff needed both by module and drush command. Functions that need to differ for versions of Drupal.

Code

function module_builder_create_directory(&$directory, $common = FALSE) {
  if (substr($directory, 0, 1) == '/') {

    // absolute path

    //print 'starts with /';
  }
  else {

    // Relative, and so assumed to be in Drupal's files folder: prepend this to
    // the given directory.
    $directory = 'public://' . $directory;
  }

  // If the directory is common, append the version number subdir.
  if ($common) {

    // There may or may not be a trailing slash: trim to make sure.
    $directory = rtrim($directory, '/');
    $directory = $directory . '/' . _module_builder_drupal_major_version();
  }
  $status = file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);

  // @todo: check $status for errors
}