List file on webduino

73 views
Skip to first unread message

xosa...@gmail.com

unread,
Apr 4, 2013, 3:51:16 PM4/4/13
to webd...@googlegroups.com
Hi , i need to list my file who are on SD and print on my website with webduino.
I get an exemple but it's not with webduino and it's doesn't work ^^" .

A part of code :
void ListFiles(WebServer &client, uint8_t flags) {
  // This code is just copied from SdFile.cpp in the SDFat library
  // and tweaked to print to the client output in html!
  dir_t p;
 
  root.rewind();
  client.println("<ul>");
  while (root.readDir(p) > 0) {
    // done if past last used entry
    if (p.name[0] == DIR_NAME_FREE) break;
 
    // skip deleted entry and entries for . and  ..
    if (p.name[0] == DIR_NAME_DELETED || p.name[0] == '.') continue;
 
    // only list subdirectories and files
    if (!DIR_IS_FILE_OR_SUBDIR(&p)) continue;
 
    // print any indent spaces
    client.print("<li><a href=\"");
    for (uint8_t i = 0; i < 11; i++) {
      if (p.name[i] == ' ') continue;
      if (i == 8) {
        client.print('.');
      }
      client.print(p.name[i]);
    }
    client.print("\">");
 
    // print file name with possible blank fill
    for (uint8_t i = 0; i < 11; i++) {
      if (p.name[i] == ' ') continue;
      if (i == 8) {
        client.print('.');
      }
      client.print(p.name[i]);
    }
 
    client.print("</a>");
 
    if (DIR_IS_SUBDIR(&p)) {
      client.print('/');
    }
 
    // print modify date/time if requested
    if (flags & LS_DATE) {
       root.printFatDate(p.lastWriteDate);
       client.print(' ');
       root.printFatTime(p.lastWriteTime);
    }
    // print size if requested
    if (!DIR_IS_SUBDIR(&p) && (flags & LS_SIZE)) {
      client.print(' ');
      client.print(p.fileSize);
    }
    client.println("</li>");
  }
  client.println("</ul>");
}

Can you help me ? Thanks :)
Sorry for my english if you don't understand say it me 

Ben Combee

unread,
Apr 4, 2013, 4:11:00 PM4/4/13
to webduino
It's going to be hard to do this with the standard Ethernet shield, as both it and the SD card are connected to the same SPI pins on the Atmega controller, so you can't use the peripherals at the same time. It might work, since each one will have a separate device enable pin, but it's not something I've ever tested.  I'd really recommend against trying to serve a whole website with Webduino -- there are better, cheaper web platforms such as a Raspberry Pi model B with its SD card slot and Ethernet jack on board.


--
You received this message because you are subscribed to the Google Groups "Webduino" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webduino+u...@googlegroups.com.
To post to this group, send email to webd...@googlegroups.com.
Visit this group at http://groups.google.com/group/webduino?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages