MCPcopy Create free account
hub / github.com/baldurk/renderdoc / RGPSupportsInterop

Method RGPSupportsInterop

qrenderdoc/Code/RGPInterop.cpp:30–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28#include <QTcpSocket>
29
30bool RGPInterop::RGPSupportsInterop(const QString &RGPPath)
31{
32 uint32_t majorVersion = 0;
33 uint32_t minorVersion = 0;
34
35 const char *searchString = "RGPVersion=";
36 const int searchStringLength = (int)strlen(searchString);
37
38 // look for an embedded string in the exe
39 QFile f(RGPPath);
40 if(f.open(QIODevice::ReadOnly))
41 {
42 QByteArray contents = f.readAll();
43
44 int search = 0;
45 do
46 {
47 int needle = contents.indexOf("RGPVersion=", search);
48
49 if(needle == -1)
50 break;
51
52 search = needle + searchStringLength;
53
54 // bail if there isn't enough room for the string plus X.Y
55 if(contents.size() - needle < searchStringLength + 3)
56 break;
57
58 // get the major version number
59 const char *major = contents.data() + search;
60
61 const char *sep = major;
62
63 // find the separator
64 while(*sep >= '0' && *sep <= '9')
65 sep++;
66
67 // get the minor version number
68 const char *minor = sep + 1;
69
70 const char *end = minor;
71
72 // find the end
73 while(*end >= '0' && *end <= '9')
74 end++;
75
76 // convert the strings to integers
77 QByteArray majorStr(major, sep - major);
78 QByteArray minorStr(minor, end - minor);
79
80 bool ok = false;
81 majorVersion = majorStr.toUInt(&ok);
82
83 if(!ok)
84 {
85 majorVersion = 0;
86 continue;
87 }

Callers

nothing calls this directly

Calls 4

openMethod · 0.45
indexOfMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected