Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: FatFileSystemCpp
Diff: usbMemory.cpp
- Revision:
- 7:a6b950d25e29
- Parent:
- 6:d407fe3e0c97
- Child:
- 8:6e23bf867e38
diff -r d407fe3e0c97 -r a6b950d25e29 usbMemory.cpp
--- a/usbMemory.cpp Sat Dec 03 13:21:35 2016 +0000
+++ b/usbMemory.cpp Mon Dec 12 02:02:11 2016 +0000
@@ -67,7 +67,7 @@
}
-int32_t fileSelect( char *fileName, uint32_t *numberLine)
+int32_t fileSelect(char *fileName, uint32_t *numberLine)
{
uint32_t numMax = 0;
int32_t ans = false;
@@ -77,39 +77,24 @@
d = opendir("/" FSNAME);
- // directory check
- if ( d != NULL ) {
- while ( (p = readdir(d)) != NULL ) {
- if(NULL != strstr(p->d_name, ".prn")) {
- strcpy(fileName, p->d_name);
- DEBUG_PRINT("detect = %s\n",fileName);
- ans = true;
- continue;
+ // file check
+ sprintf(buffer,"/msc/%s",fileName);
+ fp = fopen( buffer, "r");
+ if ( fp != NULL ) {
+ char buf[256];
+ while ( NULL != fgets(buf, sizeof(buf), fp) ) {
+ DEBUG_PRINT("%s", buf);
+ numMax++;
}
+ *numberLine = numMax;
+ fclose(fp);
+ ans = true;
+
+ } else {
+ // Don't file open
+ // nothing
}
- // file check
- if (ans == true) {
- sprintf(buffer,"/msc/%s",fileName);
- fp = fopen( buffer, "r");
- if ( fp != NULL ) {
- char buf[256];
- while ( NULL != fgets(buf, sizeof(buf), fp) ) {
- DEBUG_PRINT("%s", buf);
- numMax++;
- }
- *numberLine = numMax;
- fclose(fp);
-
- } else {
- // Don't file open
- // nothing
- }
- } else {
- // nothing Directory
- }
- }
return ans;
-
}
uint32_t fileOneLineRead(char *fileName, char *data, uint32_t dataNumber, uint32_t numberLine)