void Accelerators::ReadRC(RCFile &rcFile) { resInfo.SetFlags( (resInfo.GetFlags() &~ResourceInfo::Discardable) | ResourceInfo::Pure); resInfo.ReadRC(rcFile, true); rcFile.NeedBegin(); while (rcFile.IsString() || rcFile.IsNumber()) { //int done; Key key; key.ReadRC(rcFile); keys.push_back(key); } rcFile.NeedEnd(); }
void ResourceData::ReadRC(RCFile &rcFile) { if (rcFile.IsKeyword()) { int maxLen = 1024; data = new unsigned char [maxLen]; rcFile.NeedBegin(); while (rcFile.IsNumber()) { if (len == maxLen) { maxLen += 1024; unsigned char *hold = data; data = new unsigned char [maxLen]; memcpy(data, hold, maxLen - 1024); delete [] hold; } data[len++] = rcFile.GetNumber() & 0xff; rcFile.SkipComma(); } rcFile.NeedEnd(); } else { std::string name = rcFile.GetFileName(); std::fstream in(name.c_str(), std::ios::in | std::ios::binary); if (!in.fail()) { in.seekg(0, std::ios::end); len = in.tellg(); in.seekg(0, std::ios::beg); data = new unsigned char[len]; in.read((char *)data, len); } else throw new std::runtime_error(std::string("Could not open file '") + name + "'"); } }