found bug that disabled printing from root.

This commit is contained in:
Bernhard Kubicek 2011-11-19 15:36:49 +01:00
parent 70650c331d
commit f0154de5b3

View File

@ -192,41 +192,43 @@ void CardReader::openFile(char* name,bool read)
char *fname=name; char *fname=name;
char *dirname_start,*dirname_end; char *dirname_start,*dirname_end;
dirname_start=strchr(name,'/')+1; if(name[0]=='/')
while(dirname_start!=NULL)
{ {
dirname_end=strchr(dirname_start,'/'); dirname_start=strchr(name,'/')+1;
//SERIAL_ECHO("start:");SERIAL_ECHOLN((int)(dirname_start-name)); while(dirname_start>0)
//SERIAL_ECHO("end :");SERIAL_ECHOLN((int)(dirname_end-name));
if(dirname_end!=NULL && dirname_end>dirname_start)
{ {
char subdirname[13]; dirname_end=strchr(dirname_start,'/');
strncpy(subdirname, dirname_start, dirname_end-dirname_start); //SERIAL_ECHO("start:");SERIAL_ECHOLN((int)(dirname_start-name));
subdirname[dirname_end-dirname_start]=0; //SERIAL_ECHO("end :");SERIAL_ECHOLN((int)(dirname_end-name));
SERIAL_ECHOLN(subdirname); if(dirname_end>0 && dirname_end>dirname_start)
if(!myDir.open(curDir,subdirname,O_READ))
{ {
SERIAL_PROTOCOLPGM("open failed, File: "); char subdirname[13];
SERIAL_PROTOCOL(subdirname); strncpy(subdirname, dirname_start, dirname_end-dirname_start);
SERIAL_PROTOCOLLNPGM("."); subdirname[dirname_end-dirname_start]=0;
return; SERIAL_ECHOLN(subdirname);
if(!myDir.open(curDir,subdirname,O_READ))
{
SERIAL_PROTOCOLPGM("open failed, File: ");
SERIAL_PROTOCOL(subdirname);
SERIAL_PROTOCOLLNPGM(".");
return;
}
else
;//SERIAL_ECHOLN("dive ok");
curDir=&myDir;
dirname_start=dirname_end+1;
} }
else else // the reminder after all /fsa/fdsa/ is the filename
SERIAL_ECHOLN("dive ok"); {
fname=dirname_start;
curDir=&myDir; //SERIAL_ECHOLN("remaider");
dirname_start=dirname_end+1; //SERIAL_ECHOLN(fname);
break;
}
} }
else // the reminder after all /fsa/fdsa/ is the filename
{
fname=dirname_start;
//SERIAL_ECHOLN("remaider");
//SERIAL_ECHOLN(fname);
break;
}
} }
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