Skip to content

Commit fcb20ea

Browse files
committed
Added missing File::size() method to Bridge.
1 parent 061d71e commit fcb20ea

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

libraries/Bridge/src/FileIO.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,19 @@ void File::flush() {
139139

140140
//int read(void *buf, uint16_t nbyte)
141141

142-
//uint32_t size()
142+
uint32_t File::size() {
143+
if (bridge.getBridgeVersion() < 101)
144+
return 0;
145+
uint8_t cmd[] = {'t', handle};
146+
uint8_t buff[5];
147+
bridge.transfer(cmd, 2, buff, 5);
148+
//err = res[0]; // First byte is error code
149+
uint32_t res = buff[1] << 24;
150+
res += buff[2] << 16;
151+
res += buff[3] << 8;
152+
res += buff[4];
153+
return res;
154+
}
143155

144156
void File::close() {
145157
if (mode == 255)

0 commit comments

Comments
 (0)