<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def list_file(self, commit, path, recursive=False):
 """ Lists the files in a directory. Params: * commit: A tuple, string, or Commit object representing the commit. * path: The path to the directory. * recursive: If True, continue listing the files for sub-directories. """

        req = proto.ListFileRequest(
            file=proto.File(commit=commit_from(commit), path=path)
        )
        res = self.stub.ListFile(req, metadata=self.metadata)
        file_infos = res.file_info

        if recursive:
            dirs = [f for f in file_infos if f.file_type == proto.DIR]
            files = [f for f in file_infos if f.file_type == proto.FILE]
            return sum([self.list_file(commit, d.file.path, recursive) for d in dirs], files)

        return list(file_infos)