示例#1
0
bool file_utils::read_file_to_vec(const char *pPath, uint8_vec &data)
{
    size_t data_size;
    void *p = read_file_to_heap(pPath, data_size);
    if (!p)
        return false;

    if (static_cast<uint>(data_size) != data_size)
        return false;

    if (!data.try_resize(static_cast<uint>(data_size)))
        return false;

    if (!data.grant_ownership(static_cast<uint8 *>(p), static_cast<uint>(data_size), static_cast<uint>(data_size)))
    {
        vogl_free(p);
        return false;
    }

    return true;
}