forked from Hetchell/GI-Minty
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
57 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,40 @@ | ||
#include "util.h" | ||
|
||
namespace util { | ||
std::vector<std::string> split(const std::string& content, const std::string& delimiter) { | ||
std::vector<std::string> tokens; | ||
size_t pos = 0; | ||
size_t prevPos = 0; | ||
std::string token; | ||
std::string getUAHash(std::string execPath) { | ||
auto path = std::filesystem::path(execPath).parent_path() / "pkg_version"; | ||
std::ifstream infile(path); | ||
std::string line; | ||
std::regex str_expr = std::regex("UserAssembly.dll.*\"([0-9a-f]{32})\""); | ||
auto match = std::smatch(); | ||
|
||
while ((pos = content.find(delimiter, prevPos)) != std::string::npos) { | ||
token = content.substr(prevPos, pos - prevPos); | ||
tokens.push_back(token); | ||
prevPos = pos + delimiter.length(); | ||
while (std::getline(infile, line)) { | ||
std::regex_search(line, match, str_expr); | ||
|
||
if (match.size() == 2) { | ||
return match[1].str(); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
tokens.push_back(content.substr(prevPos)); | ||
return tokens; | ||
} | ||
std::vector<std::string> split(const std::string& content, const std::string& delimiter) { | ||
std::vector<std::string> tokens; | ||
size_t pos = 0; | ||
size_t prevPos = 0; | ||
std::string token; | ||
|
||
while ((pos = content.find(delimiter, prevPos)) != std::string::npos) { | ||
token = content.substr(prevPos, pos - prevPos); | ||
tokens.push_back(token); | ||
prevPos = pos + delimiter.length(); | ||
} | ||
|
||
int64_t GetCurrentTimeMillisec() { | ||
return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count(); | ||
} | ||
tokens.push_back(content.substr(prevPos)); | ||
return tokens; | ||
} | ||
|
||
int64_t GetCurrentTimeMillisec() { | ||
return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters