You are here

function hackedProjectWebDownloader::get_temp_directory in Hacked! 7.2

Same name and namespace in other branches
  1. 6.2 includes/hacked_project.inc \hackedProjectWebDownloader::get_temp_directory()

Returns a temp directory to work in.

Parameters

$namespace: The optional namespace of the temp directory, defaults to the classname.

1 call to hackedProjectWebDownloader::get_temp_directory()
hackedProjectWebDownloader::get_destination in includes/hackedProjectWebDownloader.inc
Returns a directory to save the downloaded project into.

File

includes/hackedProjectWebDownloader.inc, line 22

Class

hackedProjectWebDownloader
Base class for downloading remote versions of projects.

Code

function get_temp_directory($namespace = NULL) {
  if (is_null($namespace)) {
    $namespace = get_class($this);
  }
  $segments = array(
    file_directory_temp(),
    'hacked-cache-' . get_current_user(),
    $namespace,
  );
  $dir = implode('/', array_filter($segments));
  if (!file_prepare_directory($dir, FILE_CREATE_DIRECTORY) && !mkdir($dir, 0775, TRUE)) {
    watchdog('hacked', 'Failed to create temp directory: %dir', array(
      '%dir' => $dir,
    ), WATCHDOG_ERROR);
    return FALSE;
  }
  return $dir;
}