Exemplo n.º 1
0
void wdll_ver_Append(const OsPath& pathname, VersionList& list)
{
	if(pathname.empty())
		return;	// avoid error in ReadVersionString

	// pathname may not have an extension (e.g. driver names from the
	// registry). note that always appending ".dll" would be incorrect
	// since some have ".sys" extension.
	OsPath modulePathname(pathname);
	if(modulePathname.Extension() == "")
		modulePathname = modulePathname.ChangeExtension(L".dll");
	const OsPath moduleName(modulePathname.Filename());

	// read file version. try this with and without FS redirection since
	// pathname might assume both.
	wchar_t versionString[500];	// enclosed in () below
	if(ReadVersionString(modulePathname, versionString, ARRAY_SIZE(versionString)) != INFO::OK)
	{
		WinScopedDisableWow64Redirection s;
		// still failed; avoid polluting list with DLLs that don't exist
		// (requiring callers to check for their existence beforehand would be
		// onerous and unreliable)
		if(ReadVersionString(modulePathname, versionString, ARRAY_SIZE(versionString)) != INFO::OK)
			return;
	}

	if(!list.empty())
		list += L", ";
	
	list += moduleName.Filename().string();
	list += L" (";
	list += versionString;
	list += L")";
}
Exemplo n.º 2
0
/* get a list of the newest/defined versions from the repo */
bool SensorUpdater::getUpdateList(VersionList* outList, const VersionList &packageVersionList, const REPOS &repo)
{
  // get the newest version from the repos
  VersionList allPackages;
  bool success = getVersionsOnServer(&allPackages, repo);

  //extract the newst version of all mandatory packages
  VersionList updatePackages;
  int i;
  parse_function_map::const_iterator iter;
  for (iter =  possible_pkgs_.begin(), i = 0; iter != possible_pkgs_.end(); ++iter, ++i) {
    // extract all packages which are mandatory to install
    VersionList temp;

    for(size_t j=0; j<allPackages.size(); j++) {
      if( allPackages[j].package_name == iter->first) {
        if (!packageVersionList.empty()) {
          // check if the version is the requested version
          if (allPackages[j] == packageVersionList[i]) {
            if (allPackages[j].package_name != packageVersionList[i].package_name) {
              std::cerr << "requested version package name and found package name does not match" << std::endl;
              exit(-1);
            }

            temp.push_back( allPackages[j] );
            break;
          }
        }
        else {
          temp.push_back( allPackages[j] );
        }
      }
    }

    // check we found the mandatory package
    if (temp.size() < 1) {
      std::cout << "[ERROR]: Could not find the required package \""
                << iter->first << "\" in the online repository!\n";
      exit(1);
    }

    // sort for version
    std::sort(temp.begin(), temp.end());

    // add the newest version of the mandatory package to the update list
    updatePackages.push_back(temp.back());
  }
  *outList = updatePackages;
  return success;
}