|
1
|
1 #include "foobar2000-sdk-pch.h"
|
|
|
2
|
|
|
3 #ifdef _WIN32
|
|
|
4 #include "componentversion.h"
|
|
|
5 #include "filesystem.h"
|
|
|
6 #include "console.h"
|
|
|
7
|
|
|
8 bool component_installation_validator::test_my_name(const char * fn) {
|
|
|
9 const char * path = core_api::get_my_full_path();
|
|
|
10 path += pfc::scan_filename(path);
|
|
|
11 bool retVal = ( strcmp(path, fn) == 0 );
|
|
|
12 PFC_ASSERT( retVal );
|
|
|
13 if (!retVal) uAddDebugEvent(pfc::format("Component rename detected: ", fn, " >> ", path));
|
|
|
14 return retVal;
|
|
|
15 }
|
|
|
16 bool component_installation_validator::have_other_file(const char * fn) {
|
|
|
17 for(int retry = 0;;) {
|
|
|
18 pfc::string_formatter path = core_api::get_my_full_path();
|
|
|
19 path.truncate(path.scan_filename());
|
|
|
20 path << fn;
|
|
|
21 try {
|
|
|
22 try {
|
|
|
23 bool v = filesystem::g_exists(path, fb2k::noAbort);
|
|
|
24 PFC_ASSERT( v );
|
|
|
25 return v;
|
|
|
26 } catch(std::exception const & e) {
|
|
|
27 FB2K_console_formatter() << "Component integrity check error: " << e << " (on: " << fn << ")";
|
|
|
28 throw;
|
|
|
29 }
|
|
|
30 } catch(exception_io_denied const &) {
|
|
|
31
|
|
|
32 } catch(exception_io_sharing_violation const &) {
|
|
|
33
|
|
|
34 } catch(exception_io_file_corrupted const &) { // happens
|
|
|
35 return false;
|
|
|
36 } catch(...) {
|
|
|
37 uBugCheck();
|
|
|
38 }
|
|
|
39 if (++retry == 10) uBugCheck();
|
|
|
40
|
|
|
41 Sleep(100);
|
|
|
42 }
|
|
|
43 }
|
|
|
44
|
|
|
45 #endif // _WIN32
|
|
|
46
|