mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-02-23 06:35:17 +01:00
Add Utils.isLinux() and Utils.isMac() helpers.
This commit is contained in:
parent
9e2b0c05c7
commit
c35d892fa6
4 changed files with 16 additions and 6 deletions
|
@ -544,7 +544,15 @@ public class Utils {
|
|||
return isAndroid == 1;
|
||||
}
|
||||
|
||||
public static boolean isLinux() {
|
||||
return System.getProperty("os.name").toLowerCase().contains("linux");
|
||||
}
|
||||
|
||||
public static boolean isWindows() {
|
||||
return System.getProperty("os.name").toLowerCase().contains("win");
|
||||
}
|
||||
|
||||
public static boolean isMac() {
|
||||
return System.getProperty("os.name").toLowerCase().contains("mac");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ public class DnsDiscovery extends MultiplexingDiscovery {
|
|||
protected ExecutorService createExecutor() {
|
||||
// Attempted workaround for reported bugs on Linux in which gethostbyname does not appear to be properly
|
||||
// thread safe and can cause segfaults on some libc versions.
|
||||
if (System.getProperty("os.name").toLowerCase().contains("linux"))
|
||||
if (Utils.isLinux())
|
||||
return Executors.newSingleThreadExecutor(new ContextPropagatingThreadFactory("DNS seed lookups"));
|
||||
else
|
||||
return Executors.newFixedThreadPool(seeds.size(), new DaemonThreadFactory("DNS seed lookups"));
|
||||
|
|
|
@ -54,15 +54,16 @@ public class BlockFileLoader implements Iterable<Block>, Iterator<Block> {
|
|||
*/
|
||||
public static List<File> getReferenceClientBlockFileList() {
|
||||
String defaultDataDir;
|
||||
String OS = System.getProperty("os.name").toLowerCase();
|
||||
if (Utils.isWindows()) {
|
||||
defaultDataDir = System.getenv("APPDATA") + "\\.bitcoin\\blocks\\";
|
||||
} else if (OS.indexOf("mac") >= 0 || (OS.indexOf("darwin") >= 0)) {
|
||||
} else if (Utils.isMac()) {
|
||||
defaultDataDir = System.getProperty("user.home") + "/Library/Application Support/Bitcoin/blocks/";
|
||||
} else {
|
||||
} else if (Utils.isLinux()) {
|
||||
defaultDataDir = System.getProperty("user.home") + "/.bitcoin/blocks/";
|
||||
} else {
|
||||
throw new RuntimeException("Unsupported system");
|
||||
}
|
||||
|
||||
|
||||
List<File> list = new LinkedList<>();
|
||||
for (int i = 0; true; i++) {
|
||||
File file = new File(defaultDataDir + String.format(Locale.US, "blk%05d.dat", i));
|
||||
|
|
|
@ -19,6 +19,7 @@ package wallettemplate;
|
|||
import com.google.common.util.concurrent.*;
|
||||
import javafx.scene.input.*;
|
||||
import org.bitcoinj.core.NetworkParameters;
|
||||
import org.bitcoinj.core.Utils;
|
||||
import org.bitcoinj.kits.WalletAppKit;
|
||||
import org.bitcoinj.params.*;
|
||||
import org.bitcoinj.utils.BriefLogFormatter;
|
||||
|
@ -74,7 +75,7 @@ public class Main extends Application {
|
|||
// Show the crash dialog for any exceptions that we don't handle and that hit the main loop.
|
||||
GuiUtils.handleCrashesOnThisThread();
|
||||
|
||||
if (System.getProperty("os.name").toLowerCase().contains("mac")) {
|
||||
if (Utils.isMac()) {
|
||||
// We could match the Mac Aqua style here, except that (a) Modena doesn't look that bad, and (b)
|
||||
// the date picker widget is kinda broken in AquaFx and I can't be bothered fixing it.
|
||||
// AquaFx.style();
|
||||
|
|
Loading…
Add table
Reference in a new issue