10 years, 10 months ago.

How to read the LocalFileSystem filesize in bytes?

Hi,

I use:

long getFileSize(FILE *fp) {
    fseek(fp, 0, SEEK_END);
    int size = ftell(fp);
    fseek(fp, 0, SEEK_SET);
    
    return size;
}

To return the filesize, unfortunately it returns a bogus number (2771) when reading this file:

<html>
<head><title>mbed LPC1768 Webserver test page</title></head>

<frameset cols="*" rows="120,*" frameborder="no">
  <frame src="control.htm">
  <frame src="about.htm" name="main">
</frameset>

<noframes>
<body>
Your browser must support frames
</body>
</noframes>
</html>

That is obviously wrong. Any ideas?

Any help would be appreciated.

Koen.

1 Answer

10 years, 10 months ago.

Woops, how embarrassing. There was a typo in the line that produces the output.

Sorry,

Koen.

Accepted Answer