def is_inside(dir, fname):
    """True if fname is inside dir.

    The parameters should typically be passed to osutils.normpath first, so
    that . and .. and repeated slashes are eliminated, and the separators
    are canonical for the platform.

    The empty string as a dir name is taken as top-of-tree and matches
    everything.
    """
    if dir == fname:
        return True
    if dir in ('', b''):
        return True
    if isinstance(dir, bytes):
        if not dir.endswith(b'/'):
            dir += b'/'
    elif not dir.endswith('/'):
        dir += '/'
    return fname.startswith(dir)
