adding helper functions to handle directory
License
adopted mgescan
license