Skip to content
Snippets Groups Projects
Commit 0cbd861f authored by Olav Morken's avatar Olav Morken
Browse files

SimpleSAML_Utilities: Add getTempDir()-function.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1761 44740490-163a-0410-bde0-09ae8108e29a
parent 250bbd43
No related branches found
No related tags found
No related merge requests found
...@@ -29,6 +29,13 @@ $config = array ( ...@@ -29,6 +29,13 @@ $config = array (
'dictionarydir' => 'dictionaries/', 'dictionarydir' => 'dictionaries/',
'loggingdir' => 'log/', 'loggingdir' => 'log/',
/*
* A directory where simpleSAMLphp can save temporary files.
*
* SimpleSAMLphp will attempt to create this directory if it doesn't exist.
*/
'tempdir' => '/tmp/simplesaml',
'version' => 'trunk', 'version' => 'trunk',
/** /**
......
...@@ -2027,6 +2027,36 @@ class SimpleSAML_Utilities { ...@@ -2027,6 +2027,36 @@ class SimpleSAML_Utilities {
} }
} }
/**
* Get temp directory path.
*
* This function retrieves the path to a directory where
* temporary files can be saved.
*
* @return string Path to temp directory, without a trailing '/'.
*/
public static function getTempDir() {
$globalConfig = SimpleSAML_Configuration::getInstance();
$tempDir = $globalConfig->getString('tempdir', '/tmp/simplesaml');
while (substr($tempDir, -1) === '/') {
$tempDir = substr($tempDir, 0, -1);
}
if (!is_dir($tempDir)) {
$ret = mkdir($tempDir, 0700, TRUE);
if (!$ret) {
throw new SimpleSAML_Error_Exception('Error creating temp dir ' .
var_export($tempDir, TRUE) . ': ' . SimpleSAML_Utilities::getLastError());
}
}
return $tempDir;
}
} }
?> ?>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment