found bug that disabled printing from root.

master
Bernhard Kubicek 13 years ago
parent 70650c331d
commit f0154de5b3

@ -192,13 +192,15 @@ void CardReader::openFile(char* name,bool read)
char *fname=name; char *fname=name;
char *dirname_start,*dirname_end; char *dirname_start,*dirname_end;
if(name[0]=='/')
{
dirname_start=strchr(name,'/')+1; dirname_start=strchr(name,'/')+1;
while(dirname_start!=NULL) while(dirname_start>0)
{ {
dirname_end=strchr(dirname_start,'/'); dirname_end=strchr(dirname_start,'/');
//SERIAL_ECHO("start:");SERIAL_ECHOLN((int)(dirname_start-name)); //SERIAL_ECHO("start:");SERIAL_ECHOLN((int)(dirname_start-name));
//SERIAL_ECHO("end :");SERIAL_ECHOLN((int)(dirname_end-name)); //SERIAL_ECHO("end :");SERIAL_ECHOLN((int)(dirname_end-name));
if(dirname_end!=NULL && dirname_end>dirname_start) if(dirname_end>0 && dirname_end>dirname_start)
{ {
char subdirname[13]; char subdirname[13];
strncpy(subdirname, dirname_start, dirname_end-dirname_start); strncpy(subdirname, dirname_start, dirname_end-dirname_start);
@ -212,7 +214,7 @@ void CardReader::openFile(char* name,bool read)
return; return;
} }
else else
SERIAL_ECHOLN("dive ok"); ;//SERIAL_ECHOLN("dive ok");
curDir=&myDir; curDir=&myDir;
dirname_start=dirname_end+1; dirname_start=dirname_end+1;
@ -226,7 +228,7 @@ void CardReader::openFile(char* name,bool read)
} }
} }
}
if(read) if(read)
{ {
if (file.open(curDir, fname, O_READ)) if (file.open(curDir, fname, O_READ))
@ -242,7 +244,9 @@ void CardReader::openFile(char* name,bool read)
} }
else else
{ {
SERIAL_PROTOCOLLNPGM("file.open failed"); SERIAL_PROTOCOLPGM("open failed, File: ");
SERIAL_PROTOCOL(fname);
SERIAL_PROTOCOLLNPGM(".");
} }
} }
else else

Loading…
Cancel
Save