Commit 9c87838d authored by Paulo Henrique Silva's avatar Paulo Henrique Silva

Add support for OS X detection.

parent 1f6c2179
...@@ -26,7 +26,8 @@ ...@@ -26,7 +26,8 @@
*******************************************************************************/ *******************************************************************************/
package com.elphel.vdt.core; package com.elphel.vdt.core;
import java.util.*; import java.util.Iterator;
import java.util.List;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.resources.IProjectDescription;
...@@ -48,6 +49,8 @@ public class Utils { ...@@ -48,6 +49,8 @@ public class Utils {
public static final int OS_WINDOWS = 1; public static final int OS_WINDOWS = 1;
public static final int OS_LINUX = 2; public static final int OS_LINUX = 2;
public static final int OS_MAC = 3;
private static int os; private static int os;
public static boolean isWindows() { public static boolean isWindows() {
...@@ -58,6 +61,10 @@ public class Utils { ...@@ -58,6 +61,10 @@ public class Utils {
return os == OS_LINUX; return os == OS_LINUX;
} }
public static boolean isMac() {
return os == OS_MAC;
}
/** Returns the pure file name without path and extensions. */ /** Returns the pure file name without path and extensions. */
public static String getPureFileName(String fileName) { public static String getPureFileName(String fileName) {
if ((fileName == null) || (fileName.length() == 0)) if ((fileName == null) || (fileName.length() == 0))
...@@ -139,6 +146,8 @@ public class Utils { ...@@ -139,6 +146,8 @@ public class Utils {
os = OS_WINDOWS; os = OS_WINDOWS;
else if (osName.indexOf("Linux") >= 0) else if (osName.indexOf("Linux") >= 0)
os = OS_LINUX; os = OS_LINUX;
else if (osName.contains("OS X"))
os = OS_MAC;
else else
MessageUI.fatalError("Unknown os.name"); MessageUI.fatalError("Unknown os.name");
} }
......
...@@ -35,6 +35,7 @@ public class OSNameGenerator extends AbstractGenerator { ...@@ -35,6 +35,7 @@ public class OSNameGenerator extends AbstractGenerator {
private static final String OS_WINDOWS = "Windows"; private static final String OS_WINDOWS = "Windows";
private static final String OS_LINUX = "Linux"; private static final String OS_LINUX = "Linux";
private static final String OS_MAC = "Mac OS X";
public String getName() { public String getName() {
return NAME; return NAME;
...@@ -51,6 +52,8 @@ public class OSNameGenerator extends AbstractGenerator { ...@@ -51,6 +52,8 @@ public class OSNameGenerator extends AbstractGenerator {
return new String[] { OS_WINDOWS }; return new String[] { OS_WINDOWS };
} else if (osName.indexOf("Linux") >= 0) { } else if (osName.indexOf("Linux") >= 0) {
return new String[] { OS_LINUX }; return new String[] { OS_LINUX };
} else if (osName.contains("OS X")) {
return new String[] { OS_MAC };
} else { } else {
MessageUI.error("Generator '" + getName() + "' failure: OS '" + osName + "' is unknown"); MessageUI.error("Generator '" + getName() + "' failure: OS '" + osName + "' is unknown");
return null; return null;
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
<paramtype kind="enum" base="String"> <paramtype kind="enum" base="String">
<item value="Windows" /> <item value="Windows" />
<item value="Linux" /> <item value="Linux" />
<item value="Mac OS X" />
</paramtype> </paramtype>
</typedef> </typedef>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment