add safe versions of file functions