files/file: add support for symbolic permission modes

This adds support for text permission modes, eg: `u=rwx,g=r,o=r`.

This is based on pull request #2816 by @chamill, refactored to work out the permission changes using bit operations instead of strings.

Any feedback is very welcome.

(I am somewhat new to python, so if anything is not very pythonic, please let me know.)