bool CRapidDownloader::parse() { FILE* f = fileSystem->propen(path, "rb"); if (f == NULL) { return false; } gzFile fp = gzdopen(fileno(f), "rb"); if (fp == Z_NULL) { fclose(f); LOG_ERROR("Could not open %s", path.c_str()); return false; } char buf[IO_BUF_SIZE]; repos.clear(); int i = 0; while (gzgets(fp, buf, sizeof(buf)) != Z_NULL) { const std::string line = buf; const std::vector<std::string> items = tokenizeString(line, ','); if (items.size() <= 2) { // create new repo from url gzclose(fp); fclose(f); LOG_ERROR("Parse Error %s, Line %d: %s", path.c_str(), i, buf); return false; } i++; CRepo repotmp = CRepo(items[1], items[0], this); repos.push_back(repotmp); } gzclose(fp); fclose(f); LOG_INFO("Found %d repos in %s", repos.size(), path.c_str()); return true; }
bool CRapidDownloader::parse() { gzFile fp=gzopen(path.c_str(), "r"); if (fp==Z_NULL) { LOG_ERROR("Could not open %s", path.c_str()); return false; } char buf[IO_BUF_SIZE]; repos.clear(); int i=0; while (gzgets(fp, buf, sizeof(buf))!=Z_NULL) { std::string tmp=buf; std::string url=getStrByIdx(tmp,',',1); i++; if (url.size()>0) { //create new repo from url CRepo repotmp=CRepo(url, this); repos.push_back(repotmp); } else { LOG_ERROR("Parse Error %s, Line %d: %s",path.c_str(),i,buf); return false; } } gzclose(fp); LOG_INFO("Found %d repos in %s",repos.size(),path.c_str()); return true; }