Skip to content

Commit f3b83a1

Browse files
add windows path support
1 parent 282464c commit f3b83a1

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/main/java/io/tiledb/cloud/TileDBClient.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public class TileDBClient{
2828

2929
private static final String homeDir = System.getProperty("user.home");
3030

31+
private static String cloudFilePath;
32+
3133
static Logger logger = Logger.getLogger(TileDBClient.class.getName());
3234

3335
private ApiClient apiClient;
@@ -42,6 +44,14 @@ public class TileDBClient{
4244
password = "";
4345
basePath = "https://api.tiledb.com/v1";
4446
loginInfoIsInJSONFile = true;
47+
48+
// set path according to OS
49+
if (System.getProperty("os.name").toLowerCase().contains("windows")){
50+
cloudFilePath = "\\.tiledb\\cloud.json";
51+
} else{
52+
cloudFilePath = "/.tiledb/cloud.json";
53+
}
54+
4555
boolean ok = false;
4656
try {
4757
ok = loadCloudJSONFileFromHome();
@@ -60,7 +70,7 @@ public class TileDBClient{
6070
* @throws IOException
6171
*/
6272
private static boolean loadCloudJSONFileFromHome() throws IOException {
63-
String fileName = homeDir + "/.tiledb/cloud.json";
73+
String fileName = homeDir + cloudFilePath;
6474

6575
File initialFile = new File(fileName);
6676
InputStream is = Files.newInputStream(initialFile.toPath());
@@ -148,7 +158,7 @@ private void writeAuthJSONFileToHome() {
148158
jsonObject.put("host", "https://api.tiledb.com");
149159
jsonObject.put("verify_ssl", verifyingSsl);
150160
try {
151-
File file = new File(homeDir + "/.tiledb/cloud.json");
161+
File file = new File(homeDir + cloudFilePath);
152162
file.getParentFile().mkdirs(); //create /.tiledb dir if not present
153163
FileWriter fileWriter = new FileWriter(file);
154164
fileWriter.write(jsonObject.toString());

0 commit comments

Comments
 (0)