-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUtils.h
66 lines (51 loc) · 2.41 KB
/
Utils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#pragma once
#define SAFE_CLOSE_HANDLE(x) \
do { \
if ((x) && INVALID_HANDLE_VALUE != (x)) { \
::CloseHandle(x); \
(x) = INVALID_HANDLE_VALUE; \
} \
} while (FALSE)
#define ARGX3(s1, s2, s3) \
(!_wcsicmp(argv[i], s1) || !_wcsicmp(argv[i], s2) || !_wcsicmp(argv[i], s3))
#define ARG(S) ARGX3(L"-" #S, L"--" #S, L"/" #S)
#define ARGPARAMCOUNT(X) ((i + X) <= (argc - 1))
LONG CALLBACK CatchUnhandledExceptionFilter(PEXCEPTION_POINTERS pExPtrs);
extern std::vector<std::wstring> error_array;
uint32_t LogErrorMessage(bool verbose, const wchar_t* fmt, ...);
std::wstring A2W(const std::string& str);
std::string W2A(const std::wstring& str);
std::wstring FormatLocalTime(time_t datetime);
bool StartsWithCaseInsensitive(const std::wstring& text, const std::wstring& prefix);
bool GetDictionaryValue(std::string& dict, std::string name, std::string defaultValue, std::string& value);
bool SanitizeContents(std::string& str);
bool StripWhitespace(std::string& str);
bool ExpandEnvironmentVariables(const wchar_t* source, std::wstring& destination);
bool DirectoryExists(std::wstring directory);
bool IsKnownFileExtension(const std::vector<std::wstring>& exts, const std::wstring& file);
bool NormalizeDriveName(std::wstring& drive);
bool NormalizeDirectoryName(std::wstring& dir);
bool NormalizeFileName(std::wstring& file);
bool NormalizeFileExtension(std::wstring& ext);
bool ParseVersion(std::wstring version, int& major, int& minor, int& build);
std::wstring GetTempporaryFilename();
int32_t CleanupTemporaryFiles();
bool UncompressZIPContentsToString(unzFile zf, std::string& str);
bool UncompressBZIPContentsToFile(BZFILE* bzf, std::wstring file);
bool UncompressGZIPContentsToFile(gzFile gzf, std::wstring file);
bool UncompressZIPContentsToFile(unzFile zf, std::wstring file);
std::wstring GetHostName();
std::wstring GetScanUtilityDirectory();
std::wstring GetReportDirectory();
std::wstring GetSignatureReportFindingsFilename();
std::wstring GetSignatureReportSummaryFilename();
std::wstring GetCARReportFindingsFilename();
std::wstring GetCARReportSummaryFilename();
class CFileVersionInfo {
public:
std::wstring productName;
std::wstring productVersion;
std::wstring fileDescription;
std::wstring fileVersion;
};
bool GetFileResourceInfo(std::wstring file, CFileVersionInfo& info);