Ejemplo n.º 1
0
 public function test_make_unique_directory()
 {
     global $CFG;
     // Create directories should be both directories, and writable.
     $firstdir = make_unique_writable_directory($CFG->tempdir);
     $this->assertTrue(is_dir($firstdir));
     $this->assertTrue(is_writable($firstdir));
     $seconddir = make_unique_writable_directory($CFG->tempdir);
     $this->assertTrue(is_dir($seconddir));
     $this->assertTrue(is_writable($seconddir));
     // Directories should be different each iteration.
     $this->assertNotEquals($firstdir, $seconddir);
 }
Ejemplo n.º 2
0
/**
 * Create a per-request directory and make sure it is writable.
 * This can only be used during the current request and will be tidied away
 * automatically afterwards.
 *
 * A new, unique directory is always created within the current request directory.
 *
 * @param bool $exceptiononerror throw exception if error encountered
 * @return string full path to directory if successful, false if not; may throw exception
 */
function make_request_directory($exceptiononerror = true)
{
    $basedir = get_request_storage_directory($exceptiononerror);
    return make_unique_writable_directory($basedir, $exceptiononerror);
}
Ejemplo n.º 3
0
 /**
  * Makes a unique writable storage for uploaded ZIP packages.
  *
  * We need the saved ZIP to survive across multiple requests so that it can
  * be used by the plugin manager after the installation is confirmed. In
  * other words, we cannot use make_request_directory() here.
  *
  * @return string full path to the directory
  */
 public function make_installfromzip_storage()
 {
     return make_unique_writable_directory(make_temp_directory('tool_installaddon'));
 }