Browse Source

Fix File.read()

teensy4-core
PaulStoffregen 4 years ago
parent
commit
928017fba3
2 changed files with 12 additions and 6 deletions
  1. +6
    -3
      teensy3/FS.h
  2. +6
    -3
      teensy4/FS.h

+ 6
- 3
teensy3/FS.h View File

virtual int available() { virtual int available() {
return (f) ? f->available() : 0; return (f) ? f->available() : 0;
} }
virtual int read() {
return (f) ? f->read() : -1;
}
virtual int peek() { virtual int peek() {
return (f) ? f->peek() : -1; return (f) ? f->peek() : -1;
} }
bool seek(uint32_t pos) { bool seek(uint32_t pos) {
return seek(pos, SeekSet); return seek(pos, SeekSet);
} }
int read() {
if (!f) return -1;
unsigned char b;
if (f->read(&b, 1) < 1) return -1;
return b;
}
size_t write(uint8_t b) { size_t write(uint8_t b) {
return write(&b, 1); return write(&b, 1);
} }

+ 6
- 3
teensy4/FS.h View File

virtual int available() { virtual int available() {
return (f) ? f->available() : 0; return (f) ? f->available() : 0;
} }
virtual int read() {
return (f) ? f->read() : -1;
}
virtual int peek() { virtual int peek() {
return (f) ? f->peek() : -1; return (f) ? f->peek() : -1;
} }
bool seek(uint32_t pos) { bool seek(uint32_t pos) {
return seek(pos, SeekSet); return seek(pos, SeekSet);
} }
int read() {
if (!f) return -1;
unsigned char b;
if (f->read(&b, 1) < 1) return -1;
return b;
}
size_t write(uint8_t b) { size_t write(uint8_t b) {
return write(&b, 1); return write(&b, 1);
} }

Loading…
Cancel
Save