FAT32 object file enumeration question
ke4pjw
Posts: 1,155
I am working with the FAT32 object by Kwabena and @Cluso99 and have ran into a challenge enumerating the root directory. I can change to that directory, but I cannot use the FAT32 listEntry method.
The documentation in the comments state that listEntry will use whatever the current directory is, but I have found that not to be the case. I have to pass the path I want to enumerate to it. It will not accept "/".
Any guidance would be appreciated.
--Terry
movedirectory(String("/"), String("/Backup")) pub movedirectory(sourcedir,destdir) if \FS.changeDirectory(sourcedir) ' I can get past this debug("Can't change to ", zstr_(sourcedir)) if \FS.listEntry(sourcedir) ' This fails debug("Can't list directory ", zstr_(sourcedir))
PS- Error is "Expected An Entry", so I guess it does not know how to deal with somone passing it the root of the filesystem. Looks like there is special code to deal with that in changeDirectory.
Comments
I modified listEntry to be able to deal with "/".
Problem solved.
I think you mildly misunderstood the API. The "correct" way of enumerating the a directory is to change into it, do
listEntries("W")
and then dolistEntries("N")
until it returns null. Though looking at it, your hack does seem like it would work, too.Yeah, I tried that. It didn't work. I had to explicitly call listEntry with the path of the working directory before it would enumerate the files by performing listEntries("N"). Dumb. Some of that dumb may have been me stumbling around in the dark without any examples too.