Exemplo n.º 1
0
bool IAsset::LoadFromFile(QString filename)
{
    PROFILE(IAsset_LoadFromFile);
    filename = filename.trimmed(); ///\todo Sanitate.
    if (filename.isEmpty())   
    {
        LogDebug("LoadFromFile failed for asset \"" + Name() + "\", given file path is empty!");
        return false;
    }

    std::vector<u8> fileData;
    bool success = LoadFileToVector(filename, fileData);
    if (!success)
    {
        LogDebug("LoadFromFile failed for file \"" + filename + "\", could not read file!");
        return false;
    }

    if (fileData.size() == 0)
    {
        LogDebug("LoadFromFile failed for file \"" + filename + "\", file size was 0!");
        return false;
    }

    // Invoke the actual virtual function to load the asset.
    // Do not allow asynchronous loading due the caller of this 
    // expects the asset to be usable when this function returns.
    return LoadFromFileInMemory(&fileData[0], fileData.size(), false);
}
Exemplo n.º 2
0
AssetLoadState IAsset::LoadFromFile(QString filename)
{
    filename = filename.trimmed(); ///\todo Sanitate.
    std::vector<u8> fileData;
    bool success = LoadFileToVector(filename.toStdString().c_str(), fileData);
    if (!success)
    {
        LogDebug("LoadFromFile failed for file \"" + filename.toStdString() + "\", could not read file!");
        return ASSET_LOAD_FAILED;
    }

    if (fileData.size() == 0)
    {
        LogDebug("LoadFromFile failed for file \"" + filename.toStdString() + "\", file size was 0!");
        return ASSET_LOAD_FAILED;
    }

    // Invoke the actual virtual function to load the asset.
    return LoadFromFileInMemory(&fileData[0], fileData.size());
}