taisei/src/rwops/rwops_ro.c
2019-08-03 20:44:22 +03:00

28 lines
639 B
C

/*
* This software is licensed under the terms of the MIT License.
* See COPYING for further information.
* ---
* Copyright (c) 2011-2019, Lukas Weber <laochailan@web.de>.
* Copyright (c) 2012-2019, Andrei Alexeyev <akari@taisei-project.org>.
*/
#include "taisei.h"
#include "rwops_ro.h"
#include "rwops_dummy.h"
static size_t ro_write(SDL_RWops *rw, const void *ptr, size_t size, size_t maxnum) {
SDL_SetError("Read-only stream");
return 0;
}
SDL_RWops *SDL_RWWrapReadOnly(SDL_RWops *src, bool autoclose) {
if(!src) {
return NULL;
}
SDL_RWops *rw = SDL_RWWrapDummy(src, autoclose);
rw->write = ro_write;
return rw;
}