Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Since it was virually no different from one, this has been replaced by a String. Additionally, the interpreter for start scripts can now be changed from cmd.exe to git bash on windows systems by using the `bash` or `sh` commands.
- Loading branch information
Showing
16 changed files
with
132 additions
and
211 deletions.
There are no files selected for viewing
77 changes: 16 additions & 61 deletions
77
SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Host/Executable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,30 @@ | ||
package net.ME1312.SubServers.Bungee.Host; | ||
|
||
import net.ME1312.SubServers.Bungee.Library.Util; | ||
|
||
import java.io.File; | ||
import java.io.Serializable; | ||
|
||
/** | ||
* Executable Variable Class | ||
* Executable String Handler Class | ||
*/ | ||
@SuppressWarnings("serial") | ||
public class Executable implements Serializable { | ||
private boolean isFile; | ||
private File File; | ||
private String Str; | ||
/** | ||
* New Executable | ||
* | ||
* @param exe Executable String or File Path | ||
*/ | ||
public Executable(String exe) { | ||
if (Util.isNull(exe)) throw new NullPointerException(); | ||
if (new File(exe).exists()) { | ||
isFile = true; | ||
File = new File(exe); | ||
Str = exe; | ||
} else { | ||
isFile = false; | ||
File = null; | ||
Str = exe; | ||
} | ||
} | ||
public class Executable { | ||
private Executable() {} | ||
|
||
/** | ||
* New Executable | ||
* Format a command to be executed | ||
* | ||
* @param path File Path | ||
* @param gitbash Git Bash location (optional) | ||
* @param exec Executable String | ||
* @return | ||
*/ | ||
public Executable(File path) { | ||
if (Util.isNull(path)) throw new NullPointerException(); | ||
isFile = true; | ||
File = path; | ||
Str = path.toString(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
String String; | ||
if (isFile) { | ||
String = File.toString(); | ||
public static String[] parse(String gitbash, String exec) { | ||
String[] cmd; | ||
if (System.getProperty("os.name").toLowerCase().indexOf("win") >= 0) { | ||
if (gitbash != null && (exec.startsWith("bash ") || exec.startsWith("sh "))) | ||
exec = "\"" + gitbash + ((gitbash.endsWith(File.separator))?"":File.separator) + "bin" + File.separatorChar + "sh.exe\" -lic \"" + | ||
exec.replace("\\", "/\\").replace("\"", "\\\"").replace("^", "^^").replace("%", "^%").replace("&", "^&").replace("<", "^<").replace(">", "^>").replace("|", "^|") + "\""; | ||
cmd = new String[]{"cmd.exe", "/q", "/c", '"'+exec+'"'}; | ||
} else { | ||
String = Str; | ||
cmd = new String[]{"sh", "-lic", exec}; | ||
} | ||
return String; | ||
} | ||
|
||
/** | ||
* Check if the Executable String is a file | ||
* | ||
* @return File Status | ||
*/ | ||
public boolean isFile() { | ||
return isFile; | ||
} | ||
|
||
/** | ||
* Get Executable File | ||
* | ||
* @return File or Null if Executable isn't a file | ||
*/ | ||
public File toFile() { | ||
return File; | ||
return cmd; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.