platform specific changes

This commit is contained in:
Craig Raw
2020-08-25 15:31:04 +02:00
parent 350bddac84
commit f8d15f73f6
10 changed files with 39 additions and 9 deletions
@@ -182,8 +182,8 @@ public class Hwi {
//To avoid doing these with every invocation, use a --onedir packaging and expand into a temp folder on OSX
//The check will still happen on first invocation, but will not thereafter
//See https://github.com/bitcoin-core/HWI/issues/327 for details
if(platform.getPlatformId().toLowerCase().equals("mac")) {
InputStream inputStream = Hwi.class.getResourceAsStream("/external/" + platform.getPlatformId().toLowerCase() + "/hwi-1.1.2-mac-amd64-signed.zip");
if(platform == Platform.OSX) {
InputStream inputStream = Hwi.class.getResourceAsStream("/external/mac/hwi-1.1.2-mac-amd64-signed.zip");
Path tempHwiDirPath = Files.createTempDirectory(TEMP_FILE_PREFIX, PosixFilePermissions.asFileAttribute(ownerExecutableWritable));
File tempHwiDir = tempHwiDirPath.toFile();
//tempHwiDir.deleteOnExit();
@@ -211,7 +211,13 @@ public class Hwi {
hwiExecutable = tempExec;
} else {
InputStream inputStream = Hwi.class.getResourceAsStream("/external/" + platform.getPlatformId().toLowerCase() + "/hwi");
InputStream inputStream;
if(platform == Platform.WINDOWS) {
inputStream = Hwi.class.getResourceAsStream("/external/windows/hwi.exe");
} else {
inputStream = Hwi.class.getResourceAsStream("/external/" + platform.getPlatformId().toLowerCase() + "/hwi");
}
Path tempExecPath = Files.createTempFile(TEMP_FILE_PREFIX, null, PosixFilePermissions.asFileAttribute(ownerExecutableWritable));
File tempExec = tempExecPath.toFile();
//tempExec.deleteOnExit();
@@ -14,6 +14,7 @@ import com.sparrowwallet.drongo.wallet.Wallet;
import com.sparrowwallet.drongo.wallet.WalletNode;
import javafx.concurrent.Service;
import javafx.concurrent.Task;
import org.controlsfx.tools.Platform;
import java.io.*;
import java.lang.reflect.Type;
@@ -33,6 +34,7 @@ public class Storage {
private static final DateFormat BACKUP_DATE_FORMAT = new SimpleDateFormat("yyyyMMddHHmmss");
public static final String SPARROW_DIR = ".sparrow";
public static final String WINDOWS_SPARROW_DIR = "Sparrow";
public static final String WALLETS_DIR = "wallets";
public static final String WALLETS_BACKUP_DIR = "backup";
public static final String HEADER_MAGIC_1 = "SPRW1";
@@ -269,10 +271,18 @@ public class Storage {
}
static File getSparrowDir() {
if(Platform.getCurrent() == Platform.WINDOWS) {
return new File(getHomeDir(), WINDOWS_SPARROW_DIR);
}
return new File(getHomeDir(), SPARROW_DIR);
}
static File getHomeDir() {
if(Platform.getCurrent() == Platform.WINDOWS) {
return new File(System.getenv("APPDATA"));
}
return new File(System.getProperty("user.home"));
}