X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fio%2Fkfile.c;h=52762bd7dfd59ea8e82ba08162b88e93c392b56f;hb=97e93eec653e38a04e94e5191bdbf5ea48edde96;hp=f8981180324ce4bb6a36b2c899b5b8d15fa3b073;hpb=a5c34c3d883f34ec1bfd4ff2bf7224738f16d822;p=bertos.git diff --git a/bertos/io/kfile.c b/bertos/io/kfile.c index f8981180..52762bd7 100644 --- a/bertos/io/kfile.c +++ b/bertos/io/kfile.c @@ -167,6 +167,29 @@ int kfile_gets_echo(struct KFile *fd, char *buf, int size, bool echo) #endif /* !CONFIG_KFILE_GETS */ +kfile_off_t kfile_copy(KFile *src, KFile *dst, kfile_off_t size) +{ + char buf[32]; + kfile_off_t cp_len = 0; + + while (size) + { + size_t len = MIN(sizeof(buf), (size_t)size); + if (kfile_read(src, buf, len) != len) + break; + + size_t wr_len = kfile_write(dst, buf, len); + cp_len += wr_len; + size -= len; + + if (wr_len != len) + break; + } + + return cp_len; +} + + /** * Move \a fd file seek position of \a offset bytes from \a whence. *