Exemplo n.º 1
0
  public static File getAppDir(String s) {
    String s1 = System.getProperty("user.home", ".");
    File file;
    switch (EnumOSMappingHelper.enumOSMappingArray[getOs().ordinal()]) {
      case 1: // '\001'
      case 2: // '\002'
        file = new File(s1, (new StringBuilder()).append('.').append(s).append('/').toString());
        break;

      case 3: // '\003'
        String s2 = System.getenv("APPDATA");
        if (s2 != null) {
          file = new File(s2, (new StringBuilder()).append(".").append(s).append('/').toString());
        } else {
          file = new File(s1, (new StringBuilder()).append('.').append(s).append('/').toString());
        }
        break;

      case 4: // '\004'
        file =
            new File(
                s1,
                (new StringBuilder()).append("Library/Application Support/").append(s).toString());
        break;

      default:
        file = new File(s1, (new StringBuilder()).append(s).append('/').toString());
        break;
    }
    if (!file.exists() && !file.mkdirs()) {
      throw new RuntimeException(
          (new StringBuilder())
              .append("The working directory could not be created: ")
              .append(file)
              .toString());
    } else {
      return file;
    }
  }