Updating code to run in both CHD3/4 and Hortonworks current releases

hadoop fs -ls -d is not compatible with releases other than CDH4. This update should work in all versions.