/**
  * Returns the appropriate working directory for storing application data. The result of this
  * method is platform dependant: On linux, it will return ~/applicationName, on windows, the
  * working directory will be located in the user's application data folder. For Mac OS systems,
  * the working directory will be placed in the proper location in "Library/Application Support".
  *
  * <p>This method will also make sure that the working directory exists. When invoked, the
  * directory and all required subfolders will be created.
  *
  * @param applicationName Name of the application, used to determine the working directory.
  * @return the appropriate working directory for storing application data.
  */
 public static File getWorkingDirectory(final String applicationName) {
   final String userHome = System.getProperty("user.home", ".");
   final File workingDirectory;
   switch (SysInfo.getPlatform()) {
     case LINUX:
     case SOLARIS:
       workingDirectory = new File(userHome, '.' + applicationName + '/');
       break;
     case WINDOWS:
       final String applicationData = System.getenv("APPDATA");
       if (applicationData != null)
         workingDirectory = new File(applicationData, "." + applicationName + '/');
       else workingDirectory = new File(userHome, '.' + applicationName + '/');
       break;
     case MACOS:
       workingDirectory = new File(userHome, "Library/Application Support/" + applicationName);
       break;
     default:
       return new File(".");
   }
   if (!workingDirectory.exists())
     if (!workingDirectory.mkdirs())
       throw new RuntimeException(
           "The working directory could not be created: " + workingDirectory);
   return workingDirectory;
 }