in ptest/src/Config.cc [254:293]
int Config::LoadCfgFile()
{
std::fstream in(Config::OssCfgFile, std::ios::in | std::ios::binary);
if (!in.good()) {
std::cout << "Open oss.ini file fail." << std::endl;
return 1;
}
char buffer[256];
char *ptr;
while (in.getline(buffer, 256)) {
ptr = strchr(buffer, '=');
if (!ptr) {
continue;
}
if (!strncmp(buffer, "AccessKeyId", 11)) {
Config::AccessKeyId = TrimQuotes(Trim(ptr + 1).c_str());
}
else if (!strncmp(buffer, "AccessKeySecret", 15)) {
Config::AccessKeySecret = TrimQuotes(Trim(ptr + 1).c_str());
}
else if (!strncmp(buffer, "Endpoint", 8)) {
Config::Endpoint = TrimQuotes(Trim(ptr + 1).c_str());
}
else if (!strncmp(buffer, "BucketName", 10)) {
Config::BucketName = TrimQuotes(Trim(ptr + 1).c_str());
}
}
if (Config::AccessKeyId.empty() ||
Config::AccessKeySecret.empty() ||
Config::Endpoint.empty() ||
Config::BucketName.empty()) {
std::cout << "one of AK, SK, endpoint and BucketName is not config, please set the oss.ini file." << std::endl;
return 1;
}
return 0;
}