Factoring some file system functions into separate library