filesystem.[ch]: Move filesystem accessing functions into a separate module.