mbed/ARM 活用事例 第3章 SDカードを使ってファイルを操作するプログラムを作る

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
sunifu
Date:
Tue Oct 04 12:57:29 2011 +0000
Commit message:

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Oct 04 12:57:29 2011 +0000
@@ -0,0 +1,29 @@
+#include "mbed.h"
+
+LocalFileSystem local("local"); 
+
+int main() {
+    DIR *d;
+    struct dirent *p;
+    FILE *fp;
+    int i=1;
+
+    fp = fopen("/local/filelist.txt","w");
+    if(fp== NULL) {
+        printf("File /local/filelist.txt could not be opened!\r\n");
+        exit(1);
+    }
+    d = opendir("/local");
+    
+    if (d != NULL) {
+        while ((p = readdir(d)) != NULL) {              
+            fprintf(fp,"[%d] - %s\r\n",i,p->d_name);
+            i++;
+        }
+    } else {
+        printf("Could not open directory!\r\n");
+        exit(1);
+    }
+    closedir(d);
+    fclose(fp);
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Oct 04 12:57:29 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/63bcd7ba4912