Skip to content

Commit af8772b

Browse files
ctruedendscho
authored andcommitted
Use PlatformUtils methods where applicable
1 parent 11926b7 commit af8772b

File tree

5 files changed

+8
-12
lines changed

5 files changed

+8
-12
lines changed

src/main/java/org/scijava/input/Accelerator.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333

3434
import java.util.regex.Pattern;
3535

36+
import org.scijava.util.PlatformUtils;
37+
3638
/**
3739
* A keyboard shortcut, consisting of a {@link KeyCode} plus
3840
* {@link InputModifiers}.
@@ -159,7 +161,7 @@ else if (components[i].equalsIgnoreCase("control") ||
159161

160162
public static boolean isCtrlReplacedWithMeta() {
161163
// FIXME: Relocate this platform-specific logic.
162-
return System.getProperty("os.name").startsWith("Mac");
164+
return PlatformUtils.isMac();
163165
}
164166

165167
// -- Helper methods --

src/main/java/org/scijava/util/FileUtils.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@ public final class FileUtils {
6666
public static final String SHORTENER_SLASH = "/";
6767
public static final String SHORTENER_ELLIPSE = "...";
6868

69-
private final static boolean isWindows =
70-
System.getProperty("os.name").startsWith("Win");
71-
7269
private FileUtils() {
7370
// prevent instantiation of utility class
7471
}
@@ -207,7 +204,7 @@ public static File urlToFile(final String url) {
207204
path = path.substring(4, index);
208205
}
209206
try {
210-
if (isWindows && path.matches("file:[A-Za-z]:.*")) {
207+
if (PlatformUtils.isWindows() && path.matches("file:[A-Za-z]:.*")) {
211208
path = "file:/" + path.substring(5);
212209
}
213210
return new File(new URL(path).toURI());

src/test/java/org/scijava/util/AppUtilsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class AppUtilsTest {
4949
public void testBaseDirectory() {
5050
assertNull(AppUtils.getBaseDirectory(new File(
5151
"/home/blub/.m2/repository/org/dscho/secret/1.0/secret-1.0.jar"), null));
52-
final String tmp = System.getProperty("os.name").startsWith("Win") ? "c:/tmp" : "/tmp";
52+
final String tmp = PlatformUtils.isWindows() ? "c:/tmp" : "/tmp";
5353
assertEquals(new File(tmp), AppUtils.getBaseDirectory(new File(
5454
tmp + "/app/target/classes"), "app"));
5555
assertEquals(new File(tmp), AppUtils.getBaseDirectory(new File(

src/test/java/org/scijava/util/FileUtilsTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@
6161
* @author Grant Harris
6262
*/
6363
public class FileUtilsTest {
64-
private final static boolean isWindows =
65-
System.getProperty("os.name").startsWith("Win");
6664

6765
@Test
6866
public void testGetPath() {
@@ -91,7 +89,7 @@ public void testGetExtension() {
9189
public void testURLToFile() throws MalformedURLException {
9290
// verify that 'file:' URL works
9391
final String jqpublic;
94-
if (isWindows) {
92+
if (PlatformUtils.isWindows()) {
9593
jqpublic = "C:/Users/jqpublic/";
9694
} else {
9795
jqpublic = "/Users/jqpublic/";
@@ -274,7 +272,7 @@ public void testListContents() throws IOException, URISyntaxException {
274272
}
275273

276274
private static void assertEqualsPath(final String a, final String b) {
277-
if (isWindows) {
275+
if (PlatformUtils.isWindows()) {
278276
assertEquals(a.replace('\\', '/'), b.replace('\\', '/'));
279277
} else {
280278
assertEquals(a, b);

src/test/java/org/scijava/util/ProcessUtilsTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ public void testStdin() {
6868
}
6969

7070
private void assumePOSIX() {
71-
final String osName = System.getProperty("os.name");
72-
assumeTrue(osName.equals("Linux") || osName.equals("Mac OS X"));
71+
assumeTrue(PlatformUtils.isPOSIX());
7372
}
7473

7574
/**

0 commit comments

Comments
 (0)