コード例 #1
0
ファイル: location_open.cpp プロジェクト: fgroen/zxtune
 DataLocation::Ptr OpenLocation(Parameters::Accessor::Ptr coreParams, Binary::Container::Ptr data, const String& subpath)
 {
   const ArchivePluginsEnumerator::Ptr usedPlugins = ArchivePluginsEnumerator::Create();
   DataLocation::Ptr resolvedLocation = boost::make_shared<UnresolvedLocation>(data);
   const Analysis::Path::Ptr sourcePath = Analysis::ParsePath(subpath, Text::MODULE_SUBPATH_DELIMITER[0]);
   for (Analysis::Path::Ptr unresolved = sourcePath; !unresolved->Empty(); unresolved = sourcePath->Extract(resolvedLocation->GetPath()->AsString()))
   {
     const String toResolve = unresolved->AsString();
     Dbg("Resolving '%1%'", toResolve);
     if (!(resolvedLocation = TryToOpenLocation(*usedPlugins, *coreParams, resolvedLocation, *unresolved)))
     {
       throw MakeFormattedError(THIS_LINE, translate("Failed to resolve subpath '%1%'."), subpath);
     }
   }
   Dbg("Resolved '%1%'", subpath);
   return resolvedLocation;
 }
コード例 #2
0
 Formats::Archived::File::Ptr FindFile(const Formats::Archived::Container& container, const Analysis::Path& path) const
 {
   Analysis::Path::Ptr resolved = Analysis::ParsePath(String(), Text::MODULE_SUBPATH_DELIMITER[0]);
   for (const Analysis::Path::Iterator::Ptr components = path.GetIterator();
        components->IsValid(); components->Next())
   {
     resolved = resolved->Append(components->Get());
     const String filename = resolved->AsString();
     Dbg("Trying '%1%'", filename);
     if (Formats::Archived::File::Ptr file = container.FindFile(filename))
     {
       Dbg("Found");
       return file;
     }
     if (!SupportDirectories)
     {
       break;
     }
   }
   return Formats::Archived::File::Ptr();
 }