import stat


def node_name(text, n, show_hash):
    """Add symbols to a node's name to differentiate file types."""
    prefix = ''
    if show_hash:
        prefix += "%s " % n.hash.encode('hex')
    if stat.S_ISDIR(n.mode):
        return '%s%s/' % (prefix, text)
    elif stat.S_ISLNK(n.mode):
        return '%s%s@' % (prefix, text)
    else:
        return '%s%s' % (prefix, text)