def get_app_dir(app_name, roaming=True, force_posix=False):
if WIN:<EOL><INDENT>key = roaming and '<STR_LIT>' or '<STR_LIT>'<EOL>folder = os.environ.get(key)<EOL>if folder is None:<EOL><INDENT>folder = os.path.expanduser('<STR_LIT>')<EOL><DEDENT>return os.path.join(folder, app_name)<EOL><DEDENT>if force_posix:<EOL><INDENT>return os.path.join(os.path.expanduser('<STR_LIT>' + _posixify(app_name)))<EOL><DEDENT>if sys.platform == '<STR_LIT>':<EOL><INDENT>return os.path.join(os.path.expanduser(<EOL>'<STR_LIT>'), app_name)<EOL><DEDENT>return os.path.join(<EOL>os.environ.get('<STR_LIT>', os.path.expanduser('<STR_LIT>')),<EOL>_posixify(app_name))<EOL>
r"""Returns the config folder for the application.  The default behavior
    is to return whatever is most appropriate for the operating system.

    To give you an idea, for an app called ``"Foo Bar"``, something like
    the following folders could be returned:

    Mac OS X:
      ``~/Library/Application Support/Foo Bar``
    Mac OS X (POSIX):
      ``~/.foo-bar``
    Unix:
      ``~/.config/foo-bar``
    Unix (POSIX):
      ``~/.foo-bar``
    Win XP (roaming):
      ``C:\Documents and Settings\<user>\Local Settings\Application Data\Foo Bar``
    Win XP (not roaming):
      ``C:\Documents and Settings\<user>\Application Data\Foo Bar``
    Win 7 (roaming):
      ``C:\Users\<user>\AppData\Roaming\Foo Bar``
    Win 7 (not roaming):
      ``C:\Users\<user>\AppData\Local\Foo Bar``

    .. versionadded:: 2.0

    :param app_name: the application name.  This should be properly capitalized
                     and can contain whitespace.
    :param roaming: controls if the folder should be roaming or not on Windows.
                    Has no affect otherwise.
    :param force_posix: if this is set to `True` then on any POSIX system the
                        folder will be stored in the home folder with a leading
                        dot instead of the XDG config home or darwin's
                        application support folder.