code: def check_existing_filename (filename, onlyfiles=True):
      
      if not os.path.exists(filename):
          raise PatoolError("file `%s' was not found" % filename)
      if not os.access(filename, os.R_OK):
          raise PatoolError("file `%s' is not readable" % filename)
      if onlyfiles and not os.path.isfile(filename):
          raise PatoolError("`%s' is not a file" % filename)
docs: Ensure that given filename is a valid, existing file.