new file and dir handling function.