Files
fastfetch/src/common/haiku/version.cpp
T

27 lines
575 B
C++
Raw Normal View History

2025-02-17 21:22:12 +08:00
extern "C" {
#include "version.h"
}
#include <File.h>
#include <AppFileInfo.h>
2026-03-29 09:28:49 +08:00
bool ffGetFileVersion(const char* filePath, FFstrbuf* version) {
2025-02-17 21:22:12 +08:00
BFile f(filePath, B_READ_ONLY);
2026-03-29 09:28:49 +08:00
if (f.InitCheck() != B_OK) {
2025-02-17 21:22:12 +08:00
return false;
2026-03-29 09:28:49 +08:00
}
2025-02-17 21:22:12 +08:00
BAppFileInfo fileInfo(&f);
2026-03-29 09:28:49 +08:00
if (f.InitCheck() != B_OK) {
2025-02-17 21:22:12 +08:00
return false;
2026-03-29 09:28:49 +08:00
}
2025-02-17 21:22:12 +08:00
version_info info;
2026-03-29 09:28:49 +08:00
if (fileInfo.GetVersionInfo(&info, B_SYSTEM_VERSION_KIND) != B_OK) {
2025-02-17 21:22:12 +08:00
return false;
2026-03-29 09:28:49 +08:00
}
2025-02-17 21:22:12 +08:00
2026-03-29 09:28:49 +08:00
ffStrbufSetF(version, "%d.%d.%d", (int) info.major, (int) info.middle, (int) info.minor);
2025-02-17 21:22:12 +08:00
return true;
}