Exemple #1
0
void Package::FireLoadEvent(const IRI &url) const
{
    if ( _loadEventHandler == nullptr )
        throw std::runtime_error(_Str("No load event handler installed to load '", url.URIString(), "'"));
    
    if ( url.Path().find(_pathBase) == 0 )
    {
        _loadEventHandler(url);
        return;
    }
    
    IRI fixed(IRI::gEPUBScheme, UniqueID(), _pathBase, url.Query(), url.Fragment());
    fixed.AddPathComponent(url.Path());
    IRI::IRICredentials creds(url.Credentials());
    fixed.SetCredentials(creds.first, creds.second);
    
    _loadEventHandler(fixed);
}
Exemple #2
0
Auto<ByteStream> Library::ReadStreamForEPubURL(const IRI &url, CFI *pRemainingCFI)
{
    CFI cfi = url.ContentFragmentIdentifier();
    if ( cfi.Empty() )
    {
        // it references a content document directly
        const Package* pkg = PackageForEPubURL(url);
        if ( pkg != nullptr )
            return pkg->ReadStreamForItemAtPath(url.Path());
    }
    else
    {
        const ManifestItem* item = ManifestItemForCFI(url, pRemainingCFI);
        if ( item != nullptr )
            return item->Reader();
    }
    
    return nullptr;
}