MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / writeKey

Method writeKey

source/ui/data/boxedReg.cpp:73–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71}
72
73void BoxedReg::writeKey(const char* path, const char* key, const char* value, bool useQuotesAroundValue) {
74 bool found = false;
75 BString section = B("[");
76 section += path;
77 section += "]";
78 section.replace("\\", "\\\\");
79 BString searchKey = B("\"");
80 searchKey += key;
81 searchKey += "\"=";
82
83 for (size_t i = 0; i < lines.size(); i++) {
84 BString& line = lines[i];
85 if (!found) {
86 if (line.startsWith(section)) {
87 found = true;
88 }
89 } else {
90 if (line.startsWith("[")) {
91 if (value) {
92 BString p = B("\"");
93 p += key;
94 p += "\"=";
95 if (useQuotesAroundValue) {
96 p += "\"";
97 }
98 p += value;
99 if (useQuotesAroundValue) {
100 p += "\"";
101 }
102 lines.insert(lines.begin() + i - 1, p);
103 }
104 return;
105 }
106 if (line.startsWith(searchKey)) {
107 if (value) {
108 line = "\"";
109 line += key;
110 line += "\"=";
111 if (useQuotesAroundValue) {
112 line += "\"";
113 }
114 line += value;
115 if (useQuotesAroundValue) {
116 line += "\"";
117 }
118 } else {
119 lines.erase(lines.begin() + i);
120 i--;
121 }
122 return;
123 }
124 }
125 }
126 if (value) {
127 BString line = B("\"");
128 line += key;
129 line += "\"=";
130 if (useQuotesAroundValue) {

Callers 5

setGDIMethod · 0.80
setRendererMethod · 0.80
setVideoMemorySizeMethod · 0.80
setMouseWarpOverrideMethod · 0.80
setWindowsVersionMethod · 0.80

Calls 8

BFunction · 0.85
replaceMethod · 0.80
startsWithMethod · 0.80
sizeMethod · 0.45
insertMethod · 0.45
beginMethod · 0.45
eraseMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected