Example #1
0
Library &LibraryFile::library()
{
    if (d->library)
    {
        return *d->library;
    }

    if (!d->nativePath.isEmpty())
    {
        d->library = new Library(d->nativePath);
    }
    else
    {
        /// @todo A mechanism to make a NativeFile out of any File via caching?

        NativeFile *native = maybeAs<NativeFile>(source());
        if (!native)
        {
            /// @throw UnsupportedSourceError Currently shared libraries are only loaded directly
            /// from native files. Other kinds of files would require a temporary native file.
            throw UnsupportedSourceError("LibraryFile::library", source()->description() +
                ": can only load from NativeFile");
        }
        d->library = new Library(native->nativePath());
    }
    return *d->library;
}
Example #2
0
Library &LibraryFile::library()
{
    if(_library)
    {
        return *_library;
    }
    
    /// @todo A method for File for making a NativeFile out of any File.
    NativeFile *native = source()->maybeAs<NativeFile>();
    if(!native)
    {
        /// @throw UnsupportedSourceError Currently shared libraries are only loaded directly
        /// from native files. Other kinds of files would require a temporary native file.
        throw UnsupportedSourceError("LibraryFile::library", source()->description() +
            ": can only load from NativeFile");
    }
    
    _library = new Library(native->nativePath());
    return *_library;
}