summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2019-11-27 14:43:52 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2019-11-27 14:43:52 +0100
commit3d30197a7f37d15da1649a9b40a24774b4aae06d (patch)
treeffa5686af360894a9b4578edff759fd2ee742ad1 /core
parent46e76a564882f4297d9f3a0644aeb758dbf9f276 (diff)
downloadRustAndDust-3d30197a7f37d15da1649a9b40a24774b4aae06d.zip
RustAndDust-3d30197a7f37d15da1649a9b40a24774b4aae06d.tar.gz
better sqlite path on unix
Diffstat (limited to 'core')
-rw-r--r--core/src/ch/asynk/rustanddust/RustAndDust.java8
-rw-r--r--core/src/ch/asynk/rustanddust/util/DB.java13
2 files changed, 12 insertions, 9 deletions
diff --git a/core/src/ch/asynk/rustanddust/RustAndDust.java b/core/src/ch/asynk/rustanddust/RustAndDust.java
index c25862f..af6dcee 100644
--- a/core/src/ch/asynk/rustanddust/RustAndDust.java
+++ b/core/src/ch/asynk/rustanddust/RustAndDust.java
@@ -65,6 +65,7 @@ public class RustAndDust extends Game
public static final String DOM = "RustAndDust";
public static final String DB_FILE = "rustanddust.sqlite";
+ public static final String CONFIG_PATH = ".config/rustanddust";
public AssetManager manager;
public Factory factory;
@@ -122,7 +123,11 @@ public class RustAndDust extends Game
{
switch (Gdx.app.getType()) {
case Desktop:
- return String.format("data/%s", DB_FILE);
+ if (!System.getProperty("os.name").startsWith("Windo")) {
+ final String dir = String.format("%s/%s", System.getProperty("user.home"), CONFIG_PATH);
+ new java.io.File(dir).mkdir();
+ return String.format("%s/%s", dir, DB_FILE);
+ }
}
return DB_FILE;
}
@@ -135,7 +140,6 @@ public class RustAndDust extends Game
debug("create() [" + Gdx.graphics.getWidth() + ";" + Gdx.graphics.getHeight() + "] " + Gdx.graphics.getDensity() + " -> " + hudCorrection);
db = new DB(Gdx.files.internal(dbFile()).path(), false);
- db.setup();
manager = new AssetManager();
factory = new Factory(this);
diff --git a/core/src/ch/asynk/rustanddust/util/DB.java b/core/src/ch/asynk/rustanddust/util/DB.java
index 21d87ed..25e3dfb 100644
--- a/core/src/ch/asynk/rustanddust/util/DB.java
+++ b/core/src/ch/asynk/rustanddust/util/DB.java
@@ -69,17 +69,16 @@ public class DB
this.db = DatabaseFactory.getNewDatabase(dbPath, DB_SCHEMA_VERSION, null, null);
this.db.setupDatabase();
this.debug = debug;
- }
- public void setup()
- {
try {
- md = MessageDigest.getInstance(DIGEST);
- } catch (java.security.NoSuchAlgorithmException e) { RustAndDust.error("NoSuchAlgorithm"); }
+ db.openOrCreateDatabase();
+ } catch (SQLiteGdxException e) {
+ RustAndDust.error(String.format("openOrCreateDatabase : %s", dbPath));
+ }
try {
- db.openOrCreateDatabase();
- } catch (SQLiteGdxException e) { RustAndDust.error("openOrCreateDatabase"); }
+ md = MessageDigest.getInstance(DIGEST);
+ } catch (java.security.NoSuchAlgorithmException e) { RustAndDust.error("NoSuchAlgorithm"); }
Boolean version = checkVersion();
if(version == null)