From eb81b0abb41472c0247c0004ef832456d38bcf81 Mon Sep 17 00:00:00 2001 From: dotasek Date: Sat, 9 Sep 2023 07:57:09 -0700 Subject: [PATCH] Path fix for Windows --- .../utilities/npm/FilesystemPackageCacheManager.java | 6 +++++- .../utilities/npm/FilesystemPackageManagerTests.java | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/FilesystemPackageCacheManager.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/FilesystemPackageCacheManager.java index 754f7921e..e9f5410bf 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/FilesystemPackageCacheManager.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/FilesystemPackageCacheManager.java @@ -146,7 +146,11 @@ public class FilesystemPackageCacheManager extends BasePackageCacheManager imple switch (mode) { case SYSTEM: - cacheFolder = new File(Utilities.path("/var", "lib", ".fhir", "packages")); + if (Utilities.isWindows()) { + cacheFolder = new File(Utilities.path("C:","ProgramData", ".fhir", "packages")); + } else { + cacheFolder = new File(Utilities.path("/var", "lib", ".fhir", "packages")); + } break; case USER: cacheFolder = new File(Utilities.path(System.getProperty("user.home"), ".fhir", "packages")); diff --git a/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/npm/FilesystemPackageManagerTests.java b/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/npm/FilesystemPackageManagerTests.java index 56be33de3..de5a7f35b 100644 --- a/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/npm/FilesystemPackageManagerTests.java +++ b/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/npm/FilesystemPackageManagerTests.java @@ -10,6 +10,7 @@ import javax.annotation.Nonnull; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.DisabledOnOs; +import org.junit.jupiter.api.condition.EnabledOnOs; import org.junit.jupiter.api.condition.OS; public class FilesystemPackageManagerTests { @@ -89,4 +90,14 @@ public class FilesystemPackageManagerTests { }; assertEquals( "/var/lib/.fhir/packages", filesystemPackageCacheManager.getFolder()); } + + @Test + @EnabledOnOs(OS.WINDOWS) + public void testSystemCacheDirectoryWin() throws IOException { + FilesystemPackageCacheManager filesystemPackageCacheManager = new FilesystemPackageCacheManager(false) { + protected void initCacheFolder() throws IOException { + } + }; + assertEquals( "C:\\ProgramData\\.fhir\\packages", filesystemPackageCacheManager.getFolder()); + } }