mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 09:49:15 +03:00
LibCore: Refactor a version-reading utility
`ArgsParser` and `AboutDialog` had the same procedure to read the version from `/res/version.ini`. Now they use the `SERENITY_VERSION` string by default. This commit refactored the version-reading utility to the new `Core::Version` namespace.
This commit is contained in:
parent
ad80d4dce0
commit
7742f37c10
Notes:
sideshowbarker
2024-07-18 04:54:26 +09:00
Author: https://github.com/i3abghany Commit: https://github.com/SerenityOS/serenity/commit/7742f37c10e Pull-request: https://github.com/SerenityOS/serenity/pull/9661 Reviewed-by: https://github.com/nico ✅ Reviewed-by: https://github.com/sppmacd
@ -31,6 +31,7 @@ set(SOURCES
|
||||
Timer.cpp
|
||||
UDPServer.cpp
|
||||
UDPSocket.cpp
|
||||
Version.cpp
|
||||
)
|
||||
|
||||
serenity_lib(LibCore core)
|
||||
|
25
Userland/Libraries/LibCore/Version.cpp
Normal file
25
Userland/Libraries/LibCore/Version.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Mahmoud Mandour <ma.mandourr@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibCore/ConfigFile.h>
|
||||
#include <LibCore/Version.h>
|
||||
|
||||
namespace Core::Version {
|
||||
|
||||
String read_long_version_string()
|
||||
{
|
||||
auto version_config = Core::ConfigFile::open("/res/version.ini");
|
||||
auto major_version = version_config->read_entry("Version", "Major", "0");
|
||||
auto minor_version = version_config->read_entry("Version", "Minor", "0");
|
||||
|
||||
StringBuilder builder;
|
||||
builder.appendff("Version {}.{}", major_version, minor_version);
|
||||
if (auto git_version = version_config->read_entry("Version", "Git", ""); git_version != "")
|
||||
builder.appendff(".g{}", git_version);
|
||||
return builder.to_string();
|
||||
}
|
||||
|
||||
}
|
@ -12,4 +12,6 @@ namespace Core::Version {
|
||||
|
||||
constexpr StringView SERENITY_VERSION = "Version 1.0"sv;
|
||||
|
||||
String read_long_version_string();
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user