diff options
Diffstat (limited to 'cmd/cmd_read.c')
-rw-r--r-- | cmd/cmd_read.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/cmd/cmd_read.c b/cmd/cmd_read.c index 68dab14..da1988c 100644 --- a/cmd/cmd_read.c +++ b/cmd/cmd_read.c @@ -5,23 +5,28 @@ #include "libcmd/cmd_parse.h" extern file_t *g_file; -extern buf_t *g_buf; +extern Buf *g_buf; extern int g_flags; int c_read( cmd_arg_t *arg ) { int ret; - if ( g_buf->buf == NULL ) + //if ( g_buf->buf == NULL ) + if (g_buf->isempty()) { - buf_resize( g_buf, g_file->blk_size ); + //buf_resize( g_buf, g_file->blk_size ); + g_buf->realloc(g_file->blk_size); } - ret = file_read_blk( g_file, g_buf->buf ); + char *buf_ptr; + int sz; + g_buf->get_ptr(&buf_ptr,&sz); + ret = file_read_blk( g_file, (uint8_t *)buf_ptr, sz ); printf("Readed %d bytes\n", ret); - if ( (ret >= 0) && (ret <= g_buf->buf_size) ) + if ( (ret >= 0) && (ret <= g_buf->size()) ) { - g_buf->size = ret; + g_buf->set_size(ret); } return 0; |