Factor directory creation into ensure_dir method.
Fixing src file permission modes.