Fat16 library send file to ethernet client

Hi All, Basically I am trying to write a file on an SD card to an ethernet client using an Arduino Ethernet. I am using the Fat 16 librray available here: http://code.google.com/p/fat16lib/ as the SD library pushes the sketch size too high.

The following are the important lines of code:

file.open("index.htm", O_READ);

I suspect it is something to do with the middle line above, but looking at the documentation for both libraries I cannot see where I am going wrong. Can anyone suggest anything or another library I could use?

Cheers in advance

Oops, forgot to say what the problem is.
The sketch runs fine, its just that when the html file is sent to the client, all I get displayed in my browser is a “<” (the first byte of the html file)

The following are the important lines of code:

You seem to be under that impression that file.read() returns more than one character. It does not.

Just re-looked at my sketch using the SD library and I have seen where I have gone wrong, I beleive it should be something along these lines:

if (file){
          while (file.available()){

Ok, that doesn't work either as there isn't a file.available() function ...

You don't have a file.available() method with that library, but you can get the file size and use a FOR loop to read that number of bytes.

Server code that uploads a file to a browser from the SD card.

//zoomkat 12/26/12
//SD server test code
//open serial monitor to see what the arduino receives
//address will look like when submited
//for use with W5100 based ethernet shields

#include <SD.h>
#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 
  192, 168, 1, 102 }; // ip in lan
byte gateway[] = { 
  192, 168, 1, 1 }; // internet access via router
byte subnet[] = { 
  255, 255, 255, 0 }; //subnet mask
EthernetServer server(84); //server port
String readString; 


void setup(){


  // disable w5100 while setting up SD
  Serial.print("Starting SD..");
  if(!SD.begin(4)) Serial.println("failed");
  else Serial.println("ok");

  Ethernet.begin(mac, ip, gateway, gateway, subnet);

void loop(){
  // Create a client connection
  EthernetClient client = server.available();
  if (client) {
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();

        //read char by char HTTP request
        if (readString.length() < 100) {
          //store characters to string 
          readString += c; 
        //if HTTP request has ended
        if (c == '\n') {

          Serial.println(readString); //print to serial monitor for debuging 

            client.println("HTTP/1.1 200 OK"); //send new page
          //client.println("Content-Type: text/html");
          client.println("Content-Type: image/jpeg");
          //client.println("Content-Type: image/gif");
          //client.println("Content-Type: application/x-javascript");
          //client.println("Content-Type: text");


          //File myFile = SD.open("boom.htm");
          File myFile = SD.open("HYPNO.JPG");
          //File myFile = SD.open("BLUEH_SL.GIF");
          //File myFile = SD.open("SERVOSLD.HTM");

          if (myFile) {

            byte clientBuf[64];
            int clientCount = 0;

              clientBuf[clientCount] = myFile.read();

              if(clientCount > 63)
                // Serial.println("Packet");
                clientCount = 0;
            //final <64 byte cleanup packet
            if(clientCount > 0) client.write(clientBuf,clientCount);            
            // close the file:
          //stopping client