Sha256: 13e2b14859a49f64f6e177cd9e21212c7a2cf4a0d28c952d7586a76edd1ecb33
Contents?: true
Size: 1.14 KB
Versions: 4
Compression:
Stored size: 1.14 KB
Contents
#include "say.h" sf_count_t say_vfile_get_size(say_vfile *file) { return file->size; } sf_count_t say_vfile_seek(sf_count_t offset, int whence, say_vfile *file) { sf_count_t start = 0; switch (whence) { case SEEK_CUR: start = file->pos; case SEEK_SET: start = 0; case SEEK_END: start = file->size; default: return file->pos; } sf_count_t new_pos = start + offset; if (new_pos < 0) file->pos = 0; else if (new_pos > file->size) file->pos = file->size; else file->pos = new_pos; return file->pos; } sf_count_t say_vfile_read(void *buf, sf_count_t count, say_vfile *file) { if (count + file->pos >= file->size) { count = file->size - file->pos; } if (count != 0) memcpy(buf, &(((char*)file->buf)[file->pos]), count); file->pos += count; return count; } sf_count_t say_vfile_write(const void *buf, sf_count_t count, say_vfile *file) { if (count + file->pos >= file->size) { count = file->size - file->pos; } if (count != 0) memcpy(&(((char*)file->buf)[file->pos]), buf, count); file->pos += count; return count; } sf_count_t say_vfile_tell(say_vfile *file) { return file->pos; }
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
ray-0.2.1 | ext/say_vfile.c |
ray-0.2.0 | ext/say_vfile.c |
ray-0.1.1 | ext/say_vfile.c |
ray-0.1.0 | ext/say_vfile.c |