def fsencoding(s, encoding=sys.getfilesystemencoding()):
    """
    Ensure the given argument is in filesystem encoding (not unicode)
    """
    if isinstance(s, unicode):
        s = s.encode(encoding)
    return s