Added ability to specify dirmode when adding a file

The dirmode was not being passed to the addFile method, rather the default value of -1 was meaning it was not possible to set permissions on the directory of a file. Created a test for this functionality and implemented the fix.