From 386115f117ca5596508a088ef6e39bfbe2a68d59 Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Sun, 20 Jun 2004 06:17:58 +0000 Subject: [PATCH] Se termina de implementar vfread() y vfwrite. Falta testeo. --- src/vfile/vfile.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/vfile/vfile.c b/src/vfile/vfile.c index aafb851..05ef241 100644 --- a/src/vfile/vfile.c +++ b/src/vfile/vfile.c @@ -127,12 +127,20 @@ int vfputc(int c, VFILE* vfp) size_t vfread(void* ptr, size_t size, size_t nmemb, VFILE* vfp) { - return 0; + int i; + size_t total = size * nmemb; + /* leo uno a uno y si hay error salgo. */ + for (i = 0; i < total && (((char*)ptr)[i] = vfgetc(vfp)) != EOF; ++i); + return i % size; } size_t vfwrite(const void *ptr, size_t size, size_t nmemb, VFILE* vfp) { - return 0; + int i; + size_t total = size * nmemb; + /* escribo uno a uno y si hay error salgo. */ + for (i = 0; i < total && (vfputc(((char*)ptr)[i], vfp)) != EOF; ++i); + return i % size; } int vfvol_close(VFILE* vfp) -- 2.43.0