Sets the compile directory and automatically appends a DIRECTORY_SEPARATOR.

@param string $dir the compile directory

@return void
@throws Exception
337709
public function setCompileDir($dir)
    {
        $this->compileDir = rtrim($dir, '/\\') . DIRECTORY_SEPARATOR;
        if (!file_exists($this->compileDir)) {
            mkdir($this->compileDir, 0777, true);
        }
        if (is_writable($this->compileDir) === false) {
            throw new Exception('The compile directory must be writable, chmod "' . $this->compileDir . '" to make it writable');
        }
    }
1360460
public function setSortDir($dir)
    {
        if (in_array($dir, [ self::DIR_ASC, self::DIR_DESC ]))
            $this->sortDir = $dir;
        else
            $this->sortDir = self::DIR_ASC;

        return $this;
    }
1332062
public static function rmdir($dir)
    {
        // List the contents of the directory table
        $dir_content = scandir ($dir);
        // Is it a directory?
        if ($dir_content!==false) {
            // For each directory entry
            foreach ($dir_content as &$entry) {
                // Unix symbolic shortcuts, we go
                if (!in_array ($entry, array ('.','..'))) {
                    // We find the path from the beginning
                    $entry = $dir.DIRECTORY_SEPARATOR. $entry;
                    // This entry is not an issue: it clears
                    if (!is_dir($entry)) {
                        unlink ($entry);
                    } else { // This entry is a folder, it again on this issue
                        self::rmdir($entry);
                    }
                }
            }
        }
        // It has erased all entries in the folder, we can now erase
        rmdir ($dir);
    }
1272235
public function setTemplateDir($dir)
    {
        $tmpDir = rtrim($dir, '/\\') . DIRECTORY_SEPARATOR;
        if (is_dir($tmpDir) === false) {
            throw new Exception('The template directory: "' . $tmpDir . '" does not exists, create the directory or specify an other location !');
        }
        $this->templateDir[] = $tmpDir;
    }
135215
public static function setup(string $dir): void
	{
		self::setupTester();
		self::setupTimezone();
		self::setupVariables($dir);
		self::setupGlobalVariables();
	}
1221998
public static function autocreate_directory($directory)
    {
        if (!file_exists($directory)) {
            mkdir($directory, 0777, true);
        }

        if (!is_writable($directory)) {
            throw new \Exception("Directory \"{$directory}\" is not writable");
        }
    }
139422
public function mkDirRecursive($dir)
	{
		$parts = explode('/', $dir);
		$path = '';
		while (!empty($parts)) {
			$path .= array_shift($parts);
			try {
				if ($path !== '') $this->mkdir($path);
			} catch (FtpException $e) {
				if (!$this->isDir($path)) {
					throw new FtpException("Cannot create directory '$path'.");
				}
			}
			$path .= '/';
		}
	}
1368369
public function setDataDirectory(string $directory)
    {
        if (!is_dir($directory)) {
            $exception = new StorageException(sprintf(StorageException::DIRECTORY_NOT_FOUND, $directory));
            $exception->setDirectory($exception);
            $exception->setProvider(static::class);
            throw $exception;
        }

        $this->dataDirectory = $directory;
    }
1128488
public void setDir(String dir)
    {
        _spanState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, HtmlConstants.DIR, dir);
    }
583995
protected function makeDirectorySafe($dir)
    {
        $count = 0;

        if (is_dir($dir)) {
            if (!is_writable($dir)) {
                throw new SystemException(Lang::get('system::lang.directory.create_fail', ['name'=>$dir]));
            }

            return;
        }

        while (!is_dir($dir) && !@mkdir($dir, 0777, true)) {
            usleep(rand(50000, 200000));

            if ($count++ > 10) {
                throw new SystemException(Lang::get('system::lang.directory.create_fail', ['name'=>$dir]));
            }
        }

        File::chmodRecursive($dir);
    }
593919
public function rmdir($dir) {
		$this->connectIfNeeded();
		$this->handle->rmdir($dir);
		$this->onFolderDeleted(new Event(['sender' => $this, 'data' => $dir]));
	}
1236917
public function handleChangeDir(string $dir = null): void
	{
		if ($dir !== null) {
			if (
				strpos($dir, '..' . DIRECTORY_SEPARATOR) !== false
				|| !is_dir($this->getBasePath() . $dir)
			) {
				throw new InvalidArgumentException;
			}
		}
		$this->path = $dir;
		$this->redrawControl('fileManagerContainer');
	}
296806
protected function deleteDirectory($dir)
    {
        $files = new RecursiveIteratorIterator(
            new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS),
            RecursiveIteratorIterator::CHILD_FIRST
        );

        foreach ($files as $fileInfo) {
            $todo = ($fileInfo->isDir() ? 'rmdir' : 'unlink');

            $todo($fileInfo->getRealPath());
        }

        rmdir($dir);
    }
523218
protected function createDir($dir)
    {
        if (!is_dir($dir) && !mkdir($dir, 0755, true)) {
            throw new \RuntimeException(
                sprintf('Unable to create cache directory %s, check permissions', $dir)
            );
        }

        if (!is_writable($dir)) {
            throw new BadPermissionException(
                sprintf('Cache directory %s is not writable, check permissions', $dir)
            );
        }
    }
405265
protected static function cleanDir($dir) {
		
		if (isset($dir[0])) {
			$dir = trim($dir);
			$dir = ($dir[0] == DIRECTORY_SEPARATOR) ? ltrim($dir, DIRECTORY_SEPARATOR) : $dir;
			$dir = ($dir[strlen($dir)-1] == DIRECTORY_SEPARATOR) ? rtrim($dir, DIRECTORY_SEPARATOR) : $dir;
		}
		
		return $dir;
		
	}
245255
public function generateMapDir($dir)
    {
        $filepath = $this->getCachePath($dir);
        if (Generator::dump($dir, $filepath) == false) {
            throw new Exception("Error writing cache to " . $filepath);
        }
    }
393928
static function setAppPath($dir)
    {
        if (is_dir($dir))
        {
            self::$app_path = $dir;
        }
        else
        {
            \Swoole\Error::info("fatal error", "app_path[$dir] is not exists.");
        }
    }