bool BundleResource::operator ==(const BundleResource& resource) const
{
  if (!this->IsValid()) return !resource.IsValid();
  if (!resource.IsValid()) return false;
  return d->archive->GetResourceContainer() == resource.d->archive->GetResourceContainer() &&
      d->archive->GetResourcePrefix() == resource.d->archive->GetResourcePrefix() &&
      this->GetResourcePath() == resource.GetResourcePath();
}
Esempio n. 2
0
int BundleResourceTest(int /*argc*/, char* /*argv*/ [])
{
  US_TEST_BEGIN("BundleResourceTest");

  FrameworkFactory factory;
  auto framework = factory.NewFramework();
  framework.Start();

  auto context = framework.GetBundleContext();
  assert(context);

  auto bundleR = testing::InstallLib(context, "TestBundleR");
  US_TEST_CONDITION_REQUIRED(bundleR &&
                               bundleR.GetSymbolicName() == "TestBundleR",
                             "Test for existing bundle TestBundleR")

  testInvalidResource(bundleR);

  Bundle executableBundle;
  try {
    executableBundle = testing::GetBundle("main", context);
    US_TEST_CONDITION_REQUIRED(executableBundle,
                               "Test installation of bundle main")
  } catch (const std::exception& e) {
    US_TEST_FAILED_MSG(<< "Install bundle exception: " << e.what())
  }

  testResourceFromExecutable(executableBundle);

  testResourceTree(bundleR);

  testResourceOperators(bundleR);

  testTextResource(bundleR);
  testTextResourceAsBinary(bundleR);
  testSpecialCharacters(bundleR);

  testBinaryResource(bundleR);

  testCompressedResource(bundleR);

  BundleResource foo = bundleR.GetResource("foo.txt");
  US_TEST_CONDITION(foo.IsValid() == true, "Valid resource")

  testResourcesFrom("TestBundleRL", framework.GetBundleContext());
  testResourcesFrom("TestBundleRA", framework.GetBundleContext());

  US_TEST_END()
}
void ShellService::LoadSchemeResource(const BundleResource& res)
{
  std::cout << "Reading " << res.GetResourcePath();
  BundleResourceStream resStream(res);
  int resBufLen = res.GetSize() + 1;
  char* resBuf = new char[resBufLen];
  resStream.read(resBuf, resBufLen);
  if (resStream.eof() || resStream.good())
  {
    resBuf[static_cast<std::size_t>(resStream.gcount())] = '\0';
    scheme_load_string(d->m_Scheme, resBuf);
  }
  else
  {
    std::cerr << "Could not read " << res.GetResourcePath() << " file from resource";
  }
  delete[] resBuf;
}
Esempio n. 4
0
bool BundleResource::operator<(const BundleResource& resource) const
{
  return this->GetResourcePath() < resource.GetResourcePath();
}