Sorry guys,
maybe I've overseen it. I found everything about opening/reading/writing files and also reading and changing timestamps. But I didn't found anything about how to enumerate all the files on the local flash. How do I do it?
My idea is to enumerate and show all files on a LCD and select the one to execute. Then change the time stamp and reset the mbed. Do you think this idea is good?
Sorry guys,
maybe I've overseen it. I found everything about opening/reading/writing files and also reading and changing timestamps. But I didn't found anything about how to enumerate all the files on the local flash. How do I do it?
My idea is to enumerate and show all files on a LCD and select the one to execute. Then change the time stamp and reset the mbed. Do you think this idea is good?
If from within the mbed compiler, you expand the mbed library object in your project, you will see a list of all the classes supported by the mbed library. Clicking on LocalFileSystem will bring up its documentation and the sample towards the top of this documentation contains the following example code:
#include "mbed.h"
LocalFileSystem local("local"); // Create the local filesystem under the name "local"
int main() {
FILE *fp = fopen("/local/out.txt", "w"); // Open "out.txt" on the local file system for writing
fprintf(fp, "Hello World!");
fclose(fp);
remove("/local/out.txt"); // Removes the file "out.txt" from the local file system
DIR *d = opendir("/local"); // Opens the root directory of the local file system
struct dirent *p;
while((p = readdir(d)) != NULL) { // Print the names of the files in the local file system
printf("%s\n", p->d_name); // to stdout.
}
closedir(d);
}
The second half of this example shows how to open the root directory of the LocalFileSystem and lists its contents. Just beware that you can only do that with the root directory on the LocalFileSystem though.
If from within the mbed compiler, you expand the mbed library object in your project, you will see a list of all the classes supported by the mbed library. Clicking on LocalFileSystem will bring up its documentation and the sample towards the top of this documentation contains the following example code:
<<code>>
#include "mbed.h"
LocalFileSystem local("local"); // Create the local filesystem under the name "local"
int main() {
FILE *fp = fopen("/local/out.txt", "w"); // Open "out.txt" on the local file system for writing
fprintf(fp, "Hello World!");
fclose(fp);
remove("/local/out.txt"); // Removes the file "out.txt" from the local file system
DIR *d = opendir("/local"); // Opens the root directory of the local file system
struct dirent *p;
while((p = readdir(d)) != NULL) { // Print the names of the files in the local file system
printf("%s\n", p->d_name); // to stdout.
}
closedir(d);
}
<</code>>
The second half of this example shows how to open the root directory of the LocalFileSystem and lists its contents. Just beware that you can only do that with the root directory on the LocalFileSystem though.
Hi Rene,
In your original question you mention "....and also reading and changing timestamps", is this possible?
Hi Rene,
In your original question you mention "....and also reading and changing timestamps", is this possible?
Important Information for this Arm website
This site uses cookies to store information on your computer.
By continuing to use our site, you consent to our cookies.
If you are not happy with the use of these cookies, please review our
Cookie Policy
to learn how they can be disabled.
By disabling cookies, some features of the site will not work.
Access Warning
You do not have the correct permissions to perform this operation.
Sorry guys, maybe I've overseen it. I found everything about opening/reading/writing files and also reading and changing timestamps. But I didn't found anything about how to enumerate all the files on the local flash. How do I do it?
My idea is to enumerate and show all files on a LCD and select the one to execute. Then change the time stamp and reset the mbed. Do you think this idea is good?