diff --git a/libraries/SD/SD.cpp b/libraries/SD/SD.cpp index ec6c7fc7b..dbe353f29 100644 --- a/libraries/SD/SD.cpp +++ b/libraries/SD/SD.cpp @@ -404,7 +404,7 @@ boolean SDClass::exists(char *filepath) { //} -boolean SDClass::makeDir(char *filepath) { +boolean SDClass::mkdir(char *filepath) { /* Makes a single directory or a heirarchy of directories. diff --git a/libraries/SD/SD.h b/libraries/SD/SD.h index f7c9fe4f6..010c608ff 100644 --- a/libraries/SD/SD.h +++ b/libraries/SD/SD.h @@ -59,7 +59,7 @@ public: // Create the requested directory heirarchy--if intermediate directories // do not exist they will be created. - boolean makeDir(char *filepath); + boolean mkdir(char *filepath); private: SdFile file; diff --git a/libraries/SD/examples/FeatureDemo/FeatureDemo.pde b/libraries/SD/examples/FeatureDemo/FeatureDemo.pde deleted file mode 100644 index b2c7eb705..000000000 --- a/libraries/SD/examples/FeatureDemo/FeatureDemo.pde +++ /dev/null @@ -1,114 +0,0 @@ -/* - - A sketch to demonstrate the features of the SD library. - -*/ - -#include - -void setup() { - - Serial.begin(9600); - - - // You always need to initialise the SD library - Serial.println("Init SD..."); - SD.begin(); - - - // This demonstrates making a directory hierarchy - Serial.println(); - Serial.println("Make directory..."); - SD.makeDir("/apple/banana/cabbage/"); - - - // You can check for the existence of specific files/directories - char *filePathOne = "/apple/banana/cabbage/"; - char *filePathTwo = "/apple/banana/cabbage/dog/"; - - Serial.println(); - - Serial.print(filePathOne); - Serial.print(" does "); - if (SD.exists(filePathOne)) { - Serial.println("exist."); - } else { - Serial.println("not exist."); - } - - Serial.print(filePathTwo); - Serial.print(" does "); - if (SD.exists(filePathTwo)) { - Serial.println("exist."); - } else { - Serial.println("not exist."); - } - - - // Demonstrate writing (and appending to existing file content) - // to a file in a subdirectory - Serial.println(); - Serial.println("Writing to 'dolphin.txt'."); - - SD.open("/apple/banana/cabbage/dolphin.txt", true); - - SD.file.println("This line was appended to the file."); - - SD.close(); - - - // Demonstrate writing to a file in the root directory and overwriting any - // existing content - Serial.println(); - Serial.println("Writing to 'top.txt'."); - - SD.open("/top.txt", true, false); - - SD.file.println("This line overwrote the previous content of the file."); - - SD.close(); - - - // Demonstrate reading from a file in a subdirectory - Serial.println(); - Serial.println("Reading 'dolphin.txt':"); - - SD.open("/apple/banana/cabbage/dolphin.txt"); - - int c; - - // This approach may be easier to follow - while(true) { - c = SD.file.read(); - if (c < 0) { - break; - } - Serial.print((char) c); - } - - SD.close(); - - - // Demonstrate reading from a file in the root directory in a slightly different way - Serial.println(); - Serial.println("Reading 'top.txt':"); - - SD.open("/top.txt"); - - // This approach is more compact - while((c = SD.file.read()) >= 0) { - Serial.print((char) c); - } - - SD.close(); - - - // Demonstration complete! - Serial.println(); - Serial.println("Done."); -} - -void loop() { -} - - diff --git a/libraries/SD/examples/ReadWrite/ReadWrite.pde b/libraries/SD/examples/ReadWrite/ReadWrite.pde new file mode 100644 index 000000000..5b05c6762 --- /dev/null +++ b/libraries/SD/examples/ReadWrite/ReadWrite.pde @@ -0,0 +1,36 @@ +#include + +File f; + +void setup() +{ + Serial.begin(9600); + Serial.print("Initializing SD card..."); + SD.begin(); + Serial.println("done."); + + f = SD.open("test.txt", true, false); + if (f) { + Serial.print("Writing to test.txt..."); + f.println("testing 1, 2, 3."); + f.close(); + Serial.println("done."); + } else { + Serial.println("error opening test.txt"); + } + + f = SD.open("test.txt"); + if (f) { + Serial.println("test.txt:"); + while (f.available()) Serial.write(f.read()); + f.close(); + } else { + Serial.println("error opening test.txt"); + } +} + +void loop() +{ +} + + diff --git a/libraries/SD/keywords.txt b/libraries/SD/keywords.txt new file mode 100644 index 000000000..72d63e813 --- /dev/null +++ b/libraries/SD/keywords.txt @@ -0,0 +1,23 @@ +####################################### +# Syntax Coloring Map SD +####################################### + +####################################### +# Datatypes (KEYWORD1) +####################################### + +SD KEYWORD1 + +####################################### +# Methods and Functions (KEYWORD2) +####################################### +begin KEYWORD2 +exists KEYWORD2 +mkdir KEYWORD2 +open KEYWORD2 +close KEYWORD2 + + +####################################### +# Constants (LITERAL1) +#######################################