Building on MSXgl, I've written a piece of code that recursively tries to walk the directory tree. Going in to a directory works fine. So from root->A->B works. However, at the end of B it should go up 1 "..". It doesn't. It goes back to "\" and forgets everything in between. Does SDCC have special parameters for recursion? I've looked at the manual but the one I have doesn't mention recursion. It seems like fib stays zero because findnextfile can't find a file after its done searching a sudirectory and going up 1 level., In this case it only reached the first directory of a list of subdirectories. because there is also root->A->C, etc.
#include #include #include // Change Directory u8 __at(0xF55E) outBuf[256]; u8 DOS_ChangeDir(const c8* path) { path; // HL __asm ex de,hl ld c, #DOS_FUNC_CHDIR // DOS routine call BDOS __endasm; } void walk(const u8* param) { Mem_Set('$',outBuf,15); DOS_FIB* fib = DOS_FindFirstEntry(param,0x37); while (fib) { if (fib->Filename[0] != '.') { String_Format(outBuf,"%s\n\r$",fib->Filename); DOS_StringOutput(outBuf); if ((fib->Attribute & 0x10) == 0x10 ) { DOS_ChangeDir(fib->Filename); walk("*.*"); DOS_ChangeDir(".."); } } fib = DOS_FindNextEntry(); } } void main() { walk("*.*"); // this is the current directory }
ログイン/登録して投稿