MCPcopy Create free account
hub / github.com/CalcProgrammer1/OpenRGB / LoadProfileToList

Method LoadProfileToList

ProfileManager.cpp:118–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116}
117
118std::vector<RGBController*> ProfileManager::LoadProfileToList
119 (
120 std::string profile_name,
121 bool sizes
122 )
123{
124 std::vector<RGBController*> temp_controllers;
125 unsigned int controller_size;
126 unsigned int controller_offset = 0;
127
128 filesystem::path filename = configuration_directory / filesystem::u8path(profile_name);
129
130 /*---------------------------------------------------------*\
131 | Determine file extension |
132 \*---------------------------------------------------------*/
133 if(sizes)
134 {
135 filename.concat(".ors");
136 }
137 else
138 {
139 if(filename.extension() != ".orp")
140 {
141 filename.concat(".orp");
142 }
143 }
144
145 /*---------------------------------------------------------*\
146 | Open input file in binary mode |
147 \*---------------------------------------------------------*/
148 std::ifstream controller_file(filename, std::ios::in | std::ios::binary);
149
150 /*---------------------------------------------------------*\
151 | Read and verify file header |
152 \*---------------------------------------------------------*/
153 char profile_string[16];
154 unsigned int profile_version;
155
156 controller_file.read(profile_string, 16);
157 controller_file.read((char *)&profile_version, sizeof(unsigned int));
158
159 /*---------------------------------------------------------*\
160 | Profile version started at 1 and protocol version started |
161 | at 0. Version 1 profiles should use protocol 0, but 2 or |
162 | greater should be synchronized |
163 \*---------------------------------------------------------*/
164 if(profile_version == 1)
165 {
166 profile_version = 0;
167 }
168
169 controller_offset += 16 + sizeof(unsigned int);
170 controller_file.seekg(controller_offset);
171
172 if(strcmp(profile_string, OPENRGB_PROFILE_HEADER) == 0)
173 {
174 if(profile_version <= OPENRGB_PROFILE_VERSION)
175 {

Callers 2

ResourceManagerMethod · 0.80

Calls 3

ReadDeviceDescriptionMethod · 0.80
readMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected