fix for local app data on non-windows systems

This commit is contained in:
Greg DiCristofaro 2023-08-23 12:59:58 -04:00
parent 2ec56b2dba
commit 6e5e2ff2f5

View File

@ -20,6 +20,7 @@ import java.nio.file.Paths;
import java.util.Objects; import java.util.Objects;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.apache.commons.lang3.StringUtils;
import org.openide.modules.Places; import org.openide.modules.Places;
/** /**
@ -38,7 +39,11 @@ public class CTSettings {
LOGGER.log(Level.INFO, "Application Data (test mode) Path: " + Places.getUserDirectory().getAbsolutePath()); LOGGER.log(Level.INFO, "Application Data (test mode) Path: " + Places.getUserDirectory().getAbsolutePath());
return Places.getUserDirectory().getAbsolutePath(); return Places.getUserDirectory().getAbsolutePath();
} else { } else {
Path localAppPath = Paths.get(System.getenv("LOCALAPPDATA"), "cybertriage");
Path localAppPath = StringUtils.isBlank(System.getenv("LOCALAPPDATA"))
? Places.getUserDirectory().toPath().toAbsolutePath()
: Paths.get(System.getenv("LOCALAPPDATA"), "cybertriage");
try { try {
Files.createDirectories(localAppPath); Files.createDirectories(localAppPath);
LOGGER.log(Level.INFO, "Application Data Path: " + localAppPath.toString()); LOGGER.log(Level.INFO, "Application Data Path: " + localAppPath.toString());