Esempio n. 1
0
AssetID Assets::LoadFromBuffer(
    const string & ext,
    const string & name,
    const std::vector<uint8_t> & buffer) {

    Decoder * dec = GetDecoder(ext);
    if (!dec) return AssetID();


    // query the asset
    AssetID index = Query(dec->GetType(), name);
    if (index.Valid()) {
        return index;
    }

    Asset * out = NULL;


    out = (*dec)(
        name.c_str(),
        ext,
        &buffer[0],
        buffer.size()
    );



    if (!out) {
        Console::Error()  << "[Dynacoe::Assets]: Failed to load "<< typeToString(dec->GetType())
                 << " \"" << name << "\" !" << Console::End;
        return AssetID();
    }


    return storeGen(name, out, dec->GetType());
}
Esempio n. 2
0
AssetID Assets::Load(const string & ext, const string & name, bool standard) {
    string path;



    Decoder * dec = GetDecoder(ext);
    if (!dec) return AssetID();


    if (standard) {
        path = (fSearch(name.c_str())).c_str();
        if (path == "") {
            notFoundError(dec->GetType(), name);
            return AssetID();
        }
    } else
        path = name;


    InputBuffer * f = new InputBuffer;
    f->Open(path.c_str());
    if (!f->Size()) {
        Console::Error() << "[Dynacoe::Assets]: Failed to load file " << name<< Console::End;
        delete f;
        return AssetID();
    }

    auto out =  LoadFromBuffer(
        ext,
        name,
        f->ReadBytes(f->Size())
    );

    delete f;
    return out;
}