123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
-
- #ifndef MBED_FILEHANDLE_H
- #define MBED_FILEHANDLE_H
-
- typedef int FILEHANDLE;
-
- #include <stdio.h>
-
- #if defined(__ARMCC_VERSION) || defined(__ICCARM__)
- typedef int ssize_t;
- typedef long off_t;
-
- #else
- # include <sys/types.h>
- #endif
-
- namespace mbed {
-
-
- class FileHandle {
-
- public:
-
-
- virtual ssize_t write(const void* buffer, size_t length) = 0;
-
-
-
- virtual int close() = 0;
-
-
-
- virtual ssize_t read(void* buffer, size_t length) = 0;
-
-
-
- virtual int isatty() = 0;
-
-
-
- virtual off_t lseek(off_t offset, int whence) = 0;
-
-
-
- virtual int fsync() = 0;
-
- virtual off_t flen() {
-
- off_t pos = lseek(0, SEEK_CUR);
- if(pos == -1) return -1;
-
- off_t res = lseek(0, SEEK_END);
-
- lseek(pos, SEEK_SET);
- return res;
- }
-
- virtual ~FileHandle();
- };
-
- }
-
- #endif
|