dir_list() accepted a name matching dirname exactly, so opendir() of a
file's path succeeded, and readdir() then skipped past the end of that
file's name, taking the name from whatever followed it in memory. Over
MAVFTP, listing a path such as @ROMFS/locations.txt was enough.
Match only names with a separator after dirname.
dir_list() lists a directory once, for its first file, by skipping any
file whose leading directory matches the previous file's. It compared
the directory's name without the separator after it, so "sub.txt",
which sorts just before "sub/", was taken for it and the directory was
never listed. At the top level the name was also taken to start one
character in.
Compare through the separator, from the start of the name.
dir_list() compares an entry's leading directory with the previous
entry's using memcmp() over the directory's length, which reads past the
end of the previous name when that is shorter. strncmp() stops at its
end.