8 * A temporary file/directory name
18 * @param string $prefix uniqid() prefix
19 * @param string $suffix e.g. file extension
21 public function __construct($prefix, $suffix = null) {
22 $temp = sys_get_temp_dir() . "/pharext-" . $this->getUser();
23 if (!is_dir($temp) && !mkdir($temp, 0700, true)) {
26 $this->name
= $temp ."/". uniqid($prefix) . $suffix;
29 private function getUser() {
30 if (extension_loaded("posix") && function_exists("posix_getpwuid")) {
31 return posix_getpwuid(posix_getuid())["name"];
33 return trim(`whoami
2>/dev
/null`
)
34 ?
: trim(`id
-nu
2>/dev
/null`
)
36 ?
: get_current_user();
42 public function __toString() {
43 return (string) $this->name
;