| 116 | } |
| 117 | |
| 118 | std::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 | { |
no test coverage detected