/**
- * Generic putc implementation using \a fd->write.
+ * Generic putc() implementation using \a fd->write.
*/
int kfile_putc(int _c, struct KFile *fd)
{
}
/**
- * Generic getc implementation using \a fd->read.
+ * Generic getc() implementation using \a fd->read.
*/
int kfile_getc(struct KFile *fd)
{
* Move \a fd file seek position of \a offset bytes from \a whence.
*
* This is a generic implementation of seek function, you can redefine
- * it in your local module is needed.
+ * it in your local module if needed.
*/
kfile_off_t kfile_genericSeek(struct KFile *fd, kfile_off_t offset, KSeekMode whence)
{
seek_pos = 0;
break;
case KSM_SEEK_END:
- seek_pos = fd->size - 1;
+ seek_pos = fd->size;
break;
case KSM_SEEK_CUR:
seek_pos = fd->seek_pos;
return fd->seek_pos;
}
-#if CONFIG_TEST
+/**
+ * Reopen file \a fd.
+ * This is a generic implementation that only flush file
+ * and reset seek_pos to 0.
+ */
+struct KFile * kfile_genericReopen(struct KFile *fd)
+{
+ kfile_flush(fd);
+ kfile_seek(fd, 0, KSM_SEEK_SET);
+ return fd;
+}
+
+#if CONFIG_TEST_KFILE
/**
* KFile read/write subtest.