move file-related functions to file.go