mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-23 01:32:14 -05:00
7e8dfe758c
This will be used in the DynamicLoader code, as it can't do syscalls via LibCore code. Because we can't use most of the LibCore code, we convert the versioning code in Version.cpp to use LibC uname() function.
33 lines
654 B
C++
33 lines
654 B
C++
/*
|
|
* Copyright (c) 2021, Mahmoud Mandour <ma.mandourr@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <AK/String.h>
|
|
#include <LibCore/Version.h>
|
|
|
|
#ifdef AK_OS_SERENITY
|
|
# include <sys/utsname.h>
|
|
#endif
|
|
|
|
namespace Core::Version {
|
|
|
|
ErrorOr<String> read_long_version_string()
|
|
{
|
|
#ifdef AK_OS_SERENITY
|
|
struct utsname uts;
|
|
int rc = uname(&uts);
|
|
if ((rc) < 0) {
|
|
return Error::from_syscall("uname"sv, rc);
|
|
}
|
|
auto const* version = uts.release;
|
|
auto const* git_hash = uts.version;
|
|
|
|
return String::formatted("Version {} revision {}", version, git_hash);
|
|
#else
|
|
return "Version 1.0"_string;
|
|
#endif
|
|
}
|
|
|
|
}
|