fix inDirectory to reset to the original directory in case an exception occurs
Merge pull request #1674 from freiric/master

fix inDirectory to reset to the original directory in case an exception ...