ohmu
·
2026-10-15
1extern "C" {
2#include "version.h"
3}
4
5#include <File.h>
6#include <AppFileInfo.h>
7
8bool ffGetFileVersion(const char* filePath, FFstrbuf* version) {
9 BFile f(filePath, B_READ_ONLY);
10 if (f.InitCheck() != B_OK) {
11 return false;
12 }
13
14 BAppFileInfo fileInfo(&f);
15 if (f.InitCheck() != B_OK) {
16 return false;
17 }
18
19 version_info info;
20 if (fileInfo.GetVersionInfo(&info, B_SYSTEM_VERSION_KIND) != B_OK) {
21 return false;
22 }
23
24 ffStrbufSetF(version, "%d.%d.%d", (int) info.major, (int) info.middle, (int) info.minor);
25 return true;
26}