Abstract out file system.

Should make it easier to test, reuse the code.