in reply to Unix shell ls vs readdir

Your ls solution will produce different results from your readdir solution if you have "hidden" links, such as:
.foo -> tomcat
If that is a concern for you, use ls -la