Version.cpp 654 B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * Copyright (c) 2021, Mahmoud Mandour <ma.mandourr@gmail.com>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <AK/String.h>
  7. #include <LibCore/Version.h>
  8. #ifdef AK_OS_SERENITY
  9. # include <sys/utsname.h>
  10. #endif
  11. namespace Core::Version {
  12. ErrorOr<String> read_long_version_string()
  13. {
  14. #ifdef AK_OS_SERENITY
  15. struct utsname uts;
  16. int rc = uname(&uts);
  17. if ((rc) < 0) {
  18. return Error::from_syscall("uname"sv, rc);
  19. }
  20. auto const* version = uts.release;
  21. auto const* git_hash = uts.version;
  22. return String::formatted("Version {} revision {}", version, git_hash);
  23. #else
  24. return "Version 1.0"_string;
  25. #endif
  26. }
  27. }