mirror of
https://github.com/andres-montanez/Magallanes
synced 2024-06-08 00:32:15 +02:00
[Galactica] Improve Windows compatibility
This commit is contained in:
parent
fc8da5b229
commit
a370c1c0c9
|
@ -75,6 +75,11 @@ class Runtime
|
||||||
return stripos(PHP_OS, 'WIN') === 0;
|
return stripos(PHP_OS, 'WIN') === 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function hasPosix(): bool
|
||||||
|
{
|
||||||
|
return function_exists('posix_getpwuid');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate the Release ID
|
* Generate the Release ID
|
||||||
*/
|
*/
|
||||||
|
@ -471,13 +476,13 @@ class Runtime
|
||||||
*/
|
*/
|
||||||
public function getCurrentUser(): string
|
public function getCurrentUser(): string
|
||||||
{
|
{
|
||||||
// Windows fallback
|
if ($this->hasPosix()) {
|
||||||
if (!function_exists('posix_getpwuid')) {
|
$userData = posix_getpwuid(posix_geteuid());
|
||||||
return getenv('USERNAME') ?: '';
|
return $userData['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$userData = posix_getpwuid(posix_geteuid());
|
// Windows fallback
|
||||||
return $userData['name'];
|
return strval(getenv('USERNAME'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,4 +16,9 @@ class RuntimeWindowsMockup extends RuntimeMockup
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function hasPosix(): bool
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue