Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.minecraft;
- import java.io.BufferedReader;
- import java.io.DataOutputStream;
- import java.io.File;
- import java.io.InputStream;
- import java.io.InputStreamReader;
- import java.net.HttpURLConnection;
- import java.net.URL;
- //import net.minecraft.Util_OS;
- public class Util {
- private static File workDir = null;
- // $FF: synthetic field
- private static int[] $SWITCH_TABLE$net$minecraft$Util$OS;
- public Util() {
- super();
- }
- public static File getWorkingDirectory() {
- if(workDir == null) {
- workDir = getWorkingDirectory("minecraft");
- }
- return workDir;
- }
- public static File getWorkingDirectory(String applicationName) {
- String userHome = System.getProperty("user.home", ".");
- File workingDirectory;
- switch($SWITCH_TABLE$net$minecraft$Util$OS()[getPlatform().ordinal()]) {
- case 1:
- case 2:
- workingDirectory = new File(userHome, '.' + applicationName + '/');
- break;
- case 3:
- String applicationData = System.getenv("APPDATA");
- if(applicationData != null) {
- workingDirectory = new File(applicationData, "." + applicationName + '/');
- } else {
- workingDirectory = new File(userHome, '.' + applicationName + '/');
- }
- break;
- case 4:
- workingDirectory = new File(userHome, "Library/Application Support/" + applicationName);
- break;
- default:
- workingDirectory = new File(userHome, applicationName + '/');
- }
- if(!workingDirectory.exists() && !workingDirectory.mkdirs()) {
- throw new RuntimeException("The working directory could not be created: " + workingDirectory);
- } else {
- return workingDirectory;
- }
- }
- private static Util_OS getPlatform() {
- String osName = System.getProperty("os.name").toLowerCase();
- return osName.contains("win")?Util_OS.windows:(osName.contains("mac")?Util_OS.macos:(osName.contains("solaris")?Util_OS.solaris:(osName.contains("sunos")?Util_OS.solaris:(osName.contains("linux")?Util_OS.linux:(osName.contains("unix")?Util_OS.linux:Util_OS.unknown)))));
- }
- public static String excutePost(String targetURL, String urlParameters) {
- HttpURLConnection connection = null;
- boolean var13 = false;
- String var10;
- label84: {
- try {
- var13 = true;
- URL url = new URL(targetURL);
- connection = (HttpURLConnection)url.openConnection();
- connection.setRequestMethod("POST");
- connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
- connection.setRequestProperty("Content-Length", Integer.toString(urlParameters.getBytes().length));
- connection.setRequestProperty("Content-Language", "en-US");
- connection.setUseCaches(false);
- connection.setDoInput(true);
- connection.setDoOutput(true);
- DataOutputStream e = new DataOutputStream(connection.getOutputStream());
- e.writeBytes(urlParameters);
- e.flush();
- e.close();
- InputStream is = connection.getInputStream();
- BufferedReader rd = new BufferedReader(new InputStreamReader(is));
- StringBuffer response = new StringBuffer();
- String line;
- while((line = rd.readLine()) != null) {
- response.append(line);
- response.append('\r');
- }
- rd.close();
- var10 = response.toString();
- var13 = false;
- break label84;
- } catch (Exception var14) {
- var14.printStackTrace();
- var13 = false;
- } finally {
- if(var13) {
- if(connection != null) {
- connection.disconnect();
- }
- }
- }
- if(connection != null) {
- connection.disconnect();
- }
- return null;
- }
- if(connection != null) {
- connection.disconnect();
- }
- return var10;
- }
- // $FF: synthetic method
- static int[] $SWITCH_TABLE$net$minecraft$Util$OS() {
- if($SWITCH_TABLE$net$minecraft$Util$OS != null) {
- return $SWITCH_TABLE$net$minecraft$Util$OS;
- } else {
- int[] var0 = new int[Util_OS.values().length];
- try {
- var0[Util_OS.linux.ordinal()] = 1;
- } catch (NoSuchFieldError var5) {
- ;
- }
- try {
- var0[Util_OS.macos.ordinal()] = 4;
- } catch (NoSuchFieldError var4) {
- ;
- }
- try {
- var0[Util_OS.solaris.ordinal()] = 2;
- } catch (NoSuchFieldError var3) {
- ;
- }
- try {
- var0[Util_OS.unknown.ordinal()] = 5;
- } catch (NoSuchFieldError var2) {
- ;
- }
- try {
- var0[Util_OS.windows.ordinal()] = 3;
- } catch (NoSuchFieldError var1) {
- ;
- }
- $SWITCH_TABLE$net$minecraft$Util$OS = var0;
- return var0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement