filestat.py generalized and improved for directories