|
@@ -192,41 +192,43 @@ void CardReader::openFile(char* name,bool read)
|
192
|
192
|
char *fname=name;
|
193
|
193
|
|
194
|
194
|
char *dirname_start,*dirname_end;
|
195
|
|
- dirname_start=strchr(name,'/')+1;
|
196
|
|
- while(dirname_start!=NULL)
|
|
195
|
+ if(name[0]=='/')
|
197
|
196
|
{
|
198
|
|
- dirname_end=strchr(dirname_start,'/');
|
199
|
|
- //SERIAL_ECHO("start:");SERIAL_ECHOLN((int)(dirname_start-name));
|
200
|
|
- //SERIAL_ECHO("end :");SERIAL_ECHOLN((int)(dirname_end-name));
|
201
|
|
- if(dirname_end!=NULL && dirname_end>dirname_start)
|
|
197
|
+ dirname_start=strchr(name,'/')+1;
|
|
198
|
+ while(dirname_start>0)
|
202
|
199
|
{
|
203
|
|
- char subdirname[13];
|
204
|
|
- strncpy(subdirname, dirname_start, dirname_end-dirname_start);
|
205
|
|
- subdirname[dirname_end-dirname_start]=0;
|
206
|
|
- SERIAL_ECHOLN(subdirname);
|
207
|
|
- if(!myDir.open(curDir,subdirname,O_READ))
|
|
200
|
+ dirname_end=strchr(dirname_start,'/');
|
|
201
|
+ //SERIAL_ECHO("start:");SERIAL_ECHOLN((int)(dirname_start-name));
|
|
202
|
+ //SERIAL_ECHO("end :");SERIAL_ECHOLN((int)(dirname_end-name));
|
|
203
|
+ if(dirname_end>0 && dirname_end>dirname_start)
|
208
|
204
|
{
|
209
|
|
- SERIAL_PROTOCOLPGM("open failed, File: ");
|
210
|
|
- SERIAL_PROTOCOL(subdirname);
|
211
|
|
- SERIAL_PROTOCOLLNPGM(".");
|
212
|
|
- return;
|
|
205
|
+ char subdirname[13];
|
|
206
|
+ strncpy(subdirname, dirname_start, dirname_end-dirname_start);
|
|
207
|
+ subdirname[dirname_end-dirname_start]=0;
|
|
208
|
+ SERIAL_ECHOLN(subdirname);
|
|
209
|
+ if(!myDir.open(curDir,subdirname,O_READ))
|
|
210
|
+ {
|
|
211
|
+ SERIAL_PROTOCOLPGM("open failed, File: ");
|
|
212
|
+ SERIAL_PROTOCOL(subdirname);
|
|
213
|
+ SERIAL_PROTOCOLLNPGM(".");
|
|
214
|
+ return;
|
|
215
|
+ }
|
|
216
|
+ else
|
|
217
|
+ ;//SERIAL_ECHOLN("dive ok");
|
|
218
|
+
|
|
219
|
+ curDir=&myDir;
|
|
220
|
+ dirname_start=dirname_end+1;
|
213
|
221
|
}
|
214
|
|
- else
|
215
|
|
- SERIAL_ECHOLN("dive ok");
|
216
|
|
-
|
217
|
|
- curDir=&myDir;
|
218
|
|
- dirname_start=dirname_end+1;
|
219
|
|
- }
|
220
|
|
- else // the reminder after all /fsa/fdsa/ is the filename
|
221
|
|
- {
|
222
|
|
- fname=dirname_start;
|
223
|
|
- //SERIAL_ECHOLN("remaider");
|
224
|
|
- //SERIAL_ECHOLN(fname);
|
225
|
|
- break;
|
|
222
|
+ else // the reminder after all /fsa/fdsa/ is the filename
|
|
223
|
+ {
|
|
224
|
+ fname=dirname_start;
|
|
225
|
+ //SERIAL_ECHOLN("remaider");
|
|
226
|
+ //SERIAL_ECHOLN(fname);
|
|
227
|
+ break;
|
|
228
|
+ }
|
|
229
|
+
|
226
|
230
|
}
|
227
|
|
-
|
228
|
231
|
}
|
229
|
|
-
|
230
|
232
|
if(read)
|
231
|
233
|
{
|
232
|
234
|
if (file.open(curDir, fname, O_READ))
|
|
@@ -242,7 +244,9 @@ void CardReader::openFile(char* name,bool read)
|
242
|
244
|
}
|
243
|
245
|
else
|
244
|
246
|
{
|
245
|
|
- SERIAL_PROTOCOLLNPGM("file.open failed");
|
|
247
|
+ SERIAL_PROTOCOLPGM("open failed, File: ");
|
|
248
|
+ SERIAL_PROTOCOL(fname);
|
|
249
|
+ SERIAL_PROTOCOLLNPGM(".");
|
246
|
250
|
}
|
247
|
251
|
}
|
248
|
252
|
else
|