Maslosoft Cli Shared API
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
<?php
/**
* This software package is licensed under `AGPL, Commercial` license[s].
*
* @package maslosoft/cli-shared
* @license AGPL, Commercial
*
* @copyright Copyright (c) Peter Maselkowski <pmaselkowski@gmail.com>
*/
namespace Maslosoft\Cli\Shared;
/**
* Io
*
* @author Piotr Maselkowski <pmaselkowski at gmail.com>
*/
class Io
{
/**
* Create temporary directory
*
* @param string $dir The directory where the temporary filename will be created.
* @param string $prefix The prefix of the generated temporary filename. Windows uses only the first three characters of prefix.
*
* @return string The new temporary filename (with path), or FALSE on failure.
*/
public static function tempDir($dir, $prefix = '')
{
$filename = tempnam($dir, $prefix);
$dirname = $filename . 'dir';
// Silence out errors to get return value of mkdir
$level = error_reporting();
error_reporting(0);
$mask = umask(0);
if (!mkdir($dirname, 0777))
{
return false;
}
umask($mask);
unlink($filename);
error_reporting($level);
return $dirname;
}
}
API documentation generated by ApiGen