projects
/
bertos.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Test.
[bertos.git]
/
kern
/
kfile.c
diff --git
a/kern/kfile.c
b/kern/kfile.c
index ab8016c32cda080421fd2ba2bb03103a0a50758c..28adc32a95a0bfd8ead1981c5fae002f031269b9 100644
(file)
--- a/
kern/kfile.c
+++ b/
kern/kfile.c
@@
-59,7
+59,7
@@
/**
/**
- * Generic putc implementation using \a fd->write.
+ * Generic putc
()
implementation using \a fd->write.
*/
int kfile_putc(int _c, struct KFile *fd)
{
*/
int kfile_putc(int _c, struct KFile *fd)
{
@@
-72,7
+72,7
@@
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)
{
*/
int kfile_getc(struct KFile *fd)
{
@@
-170,7
+170,7
@@
int kfile_gets_echo(struct KFile *fd, char *buf, int size, bool echo)
* Move \a fd file seek position of \a offset bytes from \a whence.
*
* This is a generic implementation of seek function, you can redefine
* 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 i
s
needed.
+ * it in your local module i
f
needed.
*/
kfile_off_t kfile_genericSeek(struct KFile *fd, kfile_off_t offset, KSeekMode whence)
{
*/
kfile_off_t kfile_genericSeek(struct KFile *fd, kfile_off_t offset, KSeekMode whence)
{
@@
-183,7
+183,7
@@
kfile_off_t kfile_genericSeek(struct KFile *fd, kfile_off_t offset, KSeekMode wh
seek_pos = 0;
break;
case KSM_SEEK_END:
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;
break;
case KSM_SEEK_CUR:
seek_pos = fd->seek_pos;
@@
-206,6
+206,18
@@
kfile_off_t kfile_genericSeek(struct KFile *fd, kfile_off_t offset, KSeekMode wh
return fd->seek_pos;
}
return fd->seek_pos;
}
+/**
+ * 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
/**
#if CONFIG_TEST
/**