Skip to content

Commit

Permalink
Merge pull request #20 from KIllin-A13/master
Browse files Browse the repository at this point in the history
mac is unix-like, constants are all caps, and multicatch FTPExeptions and IOExeptions.
  • Loading branch information
nikitakit committed Jan 3, 2015
2 parents 69972da + d176e3a commit 919940c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 28 deletions.
5 changes: 4 additions & 1 deletion plugins/FFTP/src/ucpp/utils/Console.java
Expand Up @@ -7,6 +7,9 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.enterprisedt.net.ftp.FTPException;


public class Console
{
public static void main(String[] args)
Expand All @@ -28,7 +31,7 @@ public static void main(String[] args)
else
System.out.println("you need args, try 'upload file/path ucpp'");
}
catch (Exception e1)
catch (IOException | FTPException e1)
{
System.out.println("ERROR!");
e1.printStackTrace();
Expand Down
29 changes: 10 additions & 19 deletions plugins/builder/src/ucpp/utils/OSValidator.java
Expand Up @@ -3,42 +3,33 @@
/**
* This class can be used to determine which OS the user is running
*/
public class OSValidator
{
public class OSValidator {

public static final String OS = System.getProperty("os.name").toLowerCase();

/**
* @return true if the OS is Windows false otherwise
*/
public static boolean isWindows()
{

String os = System.getProperty("os.name").toLowerCase();
public static boolean isWindows() {
// windows
return (os.indexOf("win") >= 0);
return (OS.indexOf("win") >= 0);

}

/**
* @return true if the system is a Mac false otherwise
*/
public static boolean isMac()
{

String os = System.getProperty("os.name").toLowerCase();
public static boolean isMac() {
// Mac
return (os.indexOf("mac") >= 0);

return (OS.indexOf("mac") >= 0);
}

/**
* @return true if the OS is Linux or Unix false otherwise
*/
public static boolean isUnix()
{

String os = System.getProperty("os.name").toLowerCase();
// linux or unix
return os.contains("unix") || os.contains("linux");
public static boolean isUnix() {
// linux or unix or mac (mac is unix-like os)
return OS.contains("unix") || OS.contains("linux") || isMac();

}
}
2 changes: 1 addition & 1 deletion plugins/builder/src/ucpp/utils/ReturnValue.java
Expand Up @@ -2,7 +2,7 @@

public class ReturnValue
{
public static final String lineSeparator = System.getProperty("line.separator");
public static final String LINE_SEPARATOR = System.getProperty("line.separator");

private int exit;
private String message;
Expand Down
7 changes: 2 additions & 5 deletions plugins/builder/src/ucpp/utils/SetupConfigDialog.java
@@ -1,6 +1,3 @@
/**
*
*/
package ucpp.utils;

import org.eclipse.swt.layout.GridLayout;
Expand Down Expand Up @@ -68,7 +65,7 @@ public void mouseUp(MouseEvent e)
if (!rv.wasSuccessful())
{
MessageBox mb = new MessageBox(sShell);
mb.setText("Error initializing UC++!"+ReturnValue.lineSeparator+rv.getOutput());
mb.setText("Error initializing UC++!"+ReturnValue.LINE_SEPARATOR+rv.getOutput());
}
else
{
Expand All @@ -92,7 +89,7 @@ private void createSetupType()
{
setupType = new Combo(sShell, SWT.NONE);
setupType.setText("cygwin");
if (OSValidator.isMac()||OSValidator.isUnix())
if (OSValidator.isUnix())
setupType.setItems(new String[]{"linux-windriver", "linux-gccdist"});
else if (OSValidator.isWindows())
setupType.setItems(new String[]{"windows-cygwin", "windows-git"});
Expand Down
4 changes: 2 additions & 2 deletions plugins/builder/src/ucpp/utils/Ucpp.java
Expand Up @@ -52,7 +52,7 @@ private static ReturnValue exec(String command, IProject project) throws Excepti
Runtime rt = Runtime.getRuntime();
Process pr = null;

if (OSValidator.isUnix() || OSValidator.isMac())
if (OSValidator.isUnix())
{
String path = System.getenv("PATH");
if (!path.contains("ucpp"))
Expand All @@ -77,7 +77,7 @@ else if (OSValidator.isWindows())
while ((line = input.readLine()) != null)
{
Activator.out.println(line);
lines += line + ReturnValue.lineSeparator;
lines += line + ReturnValue.LINE_SEPARATOR;
}

int exitVal = pr.waitFor();
Expand Down

0 comments on commit 919940c

Please sign in to comment.