Add common directory handling functions

Also: if you try and encrypt to a directory, it will actually encrypt to
“source.X” in that directory; likewise when when decrypting if you
attempt to decrypt to a directory (when you should have specified a
file) your data will go into “directory/decrypted”.