projects
/
bertos.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add eeprom size info.
[bertos.git]
/
bertos
/
emul
/
kfile_posix.c
diff --git
a/bertos/emul/kfile_posix.c
b/bertos/emul/kfile_posix.c
index 3fce00bcf2b46b54bde179d7c4f18b8ce6fd6d25..3bc657d689a4255ca84c7d77d4a9b2c351637ebd 100644
(file)
--- a/
bertos/emul/kfile_posix.c
+++ b/
bertos/emul/kfile_posix.c
@@
-32,11
+32,11
@@
*
* \brief KFile interface implementation in Posix systems.
*
*
* \brief KFile interface implementation in Posix systems.
*
- * \version $Id$
* \author Luca Ottaviano <lottaviano@develer.com>
*/
#include <emul/kfile_posix.h>
* \author Luca Ottaviano <lottaviano@develer.com>
*/
#include <emul/kfile_posix.h>
+#include <string.h>
static size_t kfile_posix_read(struct KFile *_fd, void *buf, size_t size)
{
static size_t kfile_posix_read(struct KFile *_fd, void *buf, size_t size)
{
@@
-63,12
+63,17
@@
static kfile_off_t kfile_posix_seek(struct KFile *_fd, kfile_off_t offset, KSeek
std_whence = SEEK_END;
break;
case KSM_SEEK_SET:
std_whence = SEEK_END;
break;
case KSM_SEEK_SET:
- /* fall */
- default:
std_whence = SEEK_SET;
std_whence = SEEK_SET;
+ break;
+ default:
+ ASSERT(0);
+ return EOF;
}
}
+ int err = fseek(fd->fp, offset, std_whence);
+ if (err)
+ return err;
- return f
seek(fd->fp, offset, std_whence
);
+ return f
tell(fd->fp
);
}
static int kfile_posix_close(struct KFile *_fd)
}
static int kfile_posix_close(struct KFile *_fd)
@@
-83,9
+88,10
@@
static int kfile_posix_flush(struct KFile *_fd)
return fflush(fd->fp);
}
return fflush(fd->fp);
}
-FILE
*
kfile_posix_init(KFilePosix *file, const char *filename, const char *mode)
+FILE
*
kfile_posix_init(KFilePosix *file, const char *filename, const char *mode)
{
{
- file->fd._type = KFT_KFILEPOSIX;
+ memset(file, 0, sizeof(*file));
+ DB(file->fd._type = KFT_KFILEPOSIX);
file->fd.read = kfile_posix_read;
file->fd.write = kfile_posix_write;
file->fd.close = kfile_posix_close;
file->fd.read = kfile_posix_read;
file->fd.write = kfile_posix_write;
file->fd.close = kfile_posix_close;