MCPcopy Create free account
hub / github.com/Squirrel/Squirrel.Windows / FindLatestAppDir

Function FindLatestAppDir

src/StubExecutable/StubExecutable.cpp:43–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41}
42
43std::wstring FindLatestAppDir()
44{
45 std::wstring ourDir;
46 ourDir.assign(FindRootAppDir());
47
48 ourDir += L"\\app-*";
49
50 WIN32_FIND_DATA fileInfo = { 0 };
51 HANDLE hFile = FindFirstFile(ourDir.c_str(), &fileInfo);
52 if (hFile == INVALID_HANDLE_VALUE) {
53 return NULL;
54 }
55
56 version::Semver200_version acc("0.0.0");
57 std::wstring acc_s;
58
59 do {
60 std::wstring appVer = fileInfo.cFileName;
61 appVer = appVer.substr(4); // Skip 'app-'
62 if (!(fileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
63 continue;
64 }
65
66 std::string s(appVer.begin(), appVer.end());
67
68 version::Semver200_version thisVer(s);
69
70 if (thisVer > acc) {
71 acc = thisVer;
72 acc_s = appVer;
73 }
74 } while (FindNextFile(hFile, &fileInfo));
75
76 if (acc == version::Semver200_version("0.0.0")) {
77 return NULL;
78 }
79
80 ourDir.assign(FindRootAppDir());
81 std::wstringstream ret;
82 ret << ourDir << L"\\app-" << acc_s;
83
84 FindClose(hFile);
85 return ret.str();
86}
87
88int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
89 _In_opt_ HINSTANCE hPrevInstance,

Callers 1

wWinMainFunction · 0.85

Calls 2

FindRootAppDirFunction · 0.85
Semver200_versionClass · 0.85

Tested by

no test coverage detected