I'm not familiar with the functions that you're using, but is there anything in the output of the function you're using to list the directory content that you could use to determine what's a directory and what isn't?
Failing that, is there a function that you can use to get the size of the object? If it has a size of 0 (zero) it's
probably a directory, anything other than that and it's a file.
I say
probably because it's
possible to get a file with zero size, but unlikely.....maybe