fixed for self update

This commit is contained in:
Lion Kortlepel 2023-12-29 00:26:24 +01:00
parent 38494bb33a
commit 5efbbaa901
No known key found for this signature in database
GPG Key ID: 4322FF2B4C71259B

View File

@ -115,12 +115,12 @@ void Update::PerformUpdate(const std::string& InvokedAs) {
while (std::getline(OsRelease, Line)) { while (std::getline(OsRelease, Line)) {
if (Line.starts_with("ID=")) { if (Line.starts_with("ID=")) {
DistroID = Line.substr(3); DistroID = Line.substr(3);
} else if (Line.starts_with("VERSION_ID=")) {
DistroVersion = Line.substr(strlen("VERSION_ID="));
} else if (Line.starts_with("VERSION_ID=\"")) { } else if (Line.starts_with("VERSION_ID=\"")) {
DistroVersion = Line.substr(strlen("VERSION_ID=")); DistroVersion = Line.substr(strlen("VERSION_ID=\""));
// skip closing quote // skip closing quote
DistroVersion = DistroVersion.substr(0, DistroVersion.size() - 1); DistroVersion = DistroVersion.substr(0, DistroVersion.size() - 1);
} else if (Line.starts_with("VERSION_ID=")) {
DistroVersion = Line.substr(strlen("VERSION_ID="));
} }
} }
} }
@ -232,10 +232,9 @@ void Update::PerformUpdate(const std::string& InvokedAs) {
auto DeleteMe = InvokedAs + ".delete_me"; auto DeleteMe = InvokedAs + ".delete_me";
std::filesystem::rename(InvokedAs, DeleteMe); std::filesystem::rename(InvokedAs, DeleteMe);
std::filesystem::rename(Temp, InvokedAs); std::filesystem::rename(Temp, InvokedAs);
std::wstring Wide(DeleteMe.begin(), DeleteMe.end()); int Attr = GetFileAttributesA(DeleteMe.c_str());
int Attr = GetFileAttributes(Wide.c_str());
if ((Attr & FILE_ATTRIBUTE_HIDDEN) == 0) { if ((Attr & FILE_ATTRIBUTE_HIDDEN) == 0) {
SetFileAttributes(Wide.c_str(), Attr | FILE_ATTRIBUTE_HIDDEN); SetFileAttributesA(DeleteMe.c_str(), Attr | FILE_ATTRIBUTE_HIDDEN);
} }
#else #else
beammp_error("Not implemented"); beammp_error("Not implemented");