EOF method

I am trying to adapt an example sketch to send a file from SD card to browser.
I have it working but I don’t receive the entire file.
The issue appears to be EOF detection. The original line of code is:

while ((c = file.read()) > 0)

I am not familiar with the language (only had Arduino a week) but, as I understand it, the ‘0’ is used as an EOF marker.
I am also assuming that this signifies null rather than zero. However, in either case, this will fail if a null or zero byte exists in the file. I have tested with a file having null as the fourth byte and I only receive a file containing 3 bytes (it should be ~8k)!

Is there a simple, reliable method of detecting EOF? Alternatively, a simple way to get the file size?

Something like: while not EOF() would have been nice but…

Any advice would be appreciated - I’ve been looking for a solution for days!

Ukzappa: The issue appears to be EOF detection. The original line of code is:

while ((c = file.read()) > 0)

When an assignment and comparison are done in the same statement, the assignment returns the value of the assignment. It seems silly to compare c to be greater than zero, when file.read() returns -1 if no more characters are available. (so >= 0 or > -1 would make more sense.)

However, I would think more appropriate method would be:

while (file.available()) {
  c = file.read();
}

As shown in this example: http://arduino.cc/en/Reference/SDopen

Thank you!

The sketch, from adafruit, clearly had a typo. Changed line to 'while ((c = file.read()) >= 0)' and it now works as expected.

I did attempt to use 'while (file.available())' the other day but no joy as it is from SD library and the adafruit sketch uses SdFat and SdFatUtil libraries. Including SD.h just created more problems!

Given that it is not possible to upload a sketch with the ethernet shield attached, testing changes was becoming rather tedious!!!

Thanks again.