diff --git a/libraries/SD/File.cpp b/libraries/SD/File.cpp index 1226f2cf4..e0ef30a9c 100644 --- a/libraries/SD/File.cpp +++ b/libraries/SD/File.cpp @@ -101,7 +101,10 @@ int File::read(void *buf, uint16_t nbyte) { int File::available() { if (! _file) return 0; - return size() - position(); + + uint32_t n = size() - position(); + + return n > 0X7FFF ? 0X7FFF : n; } void File::flush() { diff --git a/libraries/SD/examples/CardInfo/CardInfo.ino b/libraries/SD/examples/CardInfo/CardInfo.ino index 7abfd33e4..fb2f6c3ca 100644 --- a/libraries/SD/examples/CardInfo/CardInfo.ino +++ b/libraries/SD/examples/CardInfo/CardInfo.ino @@ -80,7 +80,7 @@ void setup() // print the type and size of the first FAT-type volume - long volumesize; + uint32_t volumesize; Serial.print("\nVolume type is FAT"); Serial.println(volume.fatType(), DEC); Serial.println();