From 74ff5af87119d2d0448c4712e1e4cca3d683d55e Mon Sep 17 00:00:00 2001 From: pancake Date: Mon, 17 Jan 2011 15:28:40 +0100 Subject: [PATCH] * Fix for r_io_resize -- needs merge with refactor --- libr/include/r_io.h | 1 + libr/io/io.c | 18 +++++------------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/libr/include/r_io.h b/libr/include/r_io.h index f6c4b7abd3..e1c0af9a10 100644 --- a/libr/include/r_io.h +++ b/libr/include/r_io.h @@ -193,6 +193,7 @@ R_API ut64 r_io_seek(RIO *io, ut64 offset, int whence); R_API int r_io_system(RIO *io, const char *cmd); R_API int r_io_close(RIO *io, int fd); R_API ut64 r_io_size(RIO *io, int fd); +R_API int r_io_resize(struct r_io_t *io, ut64 newsize); /* io/cache.c */ R_API void r_io_cache_commit(RIO *io); diff --git a/libr/io/io.c b/libr/io/io.c index 15ce19becc..d7bc445462 100644 --- a/libr/io/io.c +++ b/libr/io/io.c @@ -189,19 +189,11 @@ R_API ut64 r_io_read_i(struct r_io_t *io, ut64 addr, int sz, int endian) { return ret; } -R_API int r_io_resize(struct r_io_t *io, const char *file, int flags, int mode) { - // XXX not implemented -#if 0 - /* TODO */ - struct r_io_plugin_t *plugin = r_io_plugin_resolve(file); - if (plugin && io->plugin->resize) { - int fd = plugin->resize(file, flags, mode); - if (fd != -1) - r_io_plugin_open(fd, plugin); - return fd; - } -#endif - return -1; +R_API int r_io_resize(struct r_io_t *io, ut64 newsize) { + if (io->plugin && io->plugin->resize) + return io->plugin->resize (io, io->fd, newsize); + else ftruncate (io->fd, newsize); + return R_FALSE; } R_API int r_io_set_write_mask(struct r_io_t *io, const ut8 *buf, int len) {