add support for [user] in path

This commit is contained in:
Grahame Grieve 2020-02-07 10:30:17 +11:00
parent b95a05045e
commit c0976dd365
4 changed files with 35 additions and 7 deletions

View File

@ -568,11 +568,20 @@ public class Utilities {
else if (!s.toString().endsWith(File.separator))
s.append(File.separator);
String a = arg;
if ("[tmp]".equals(a)) {
if (hasCTempDir()) {
a = "c:\\temp";
} else {
a = System.getProperty("java.io.tmpdir");
if (s.length() == 0) {
if ("[tmp]".equals(a)) {
if (hasCTempDir()) {
a = "c:\\temp";
} else {
a = System.getProperty("java.io.tmpdir");
}
} else if ("[user]".equals(a)) {
a = System.getProperty("user.home");
} else if (a.startsWith("[") && a.endsWith("]")){
String ev = System.getenv(a.replace("[", "").replace("]", ""));
if (ev != null) {
a = ev;
}
}
}
a = a.replace("\\", File.separator);

View File

@ -0,0 +1,18 @@
package org.hl7.fhir.utilities.tests;
import java.io.IOException;
import org.hl7.fhir.utilities.Utilities;
import org.junit.Test;
import junit.framework.Assert;
public class UtilitiesTests {
@Test
public void testPath() throws IOException {
Assert.assertEquals(Utilities.path("[tmp]", "test.txt"), "c:\\temp\\test.txt");
Assert.assertEquals(Utilities.path("[user]", "test.txt"), System.getProperty("user.home")+"\\test.txt");
Assert.assertEquals(Utilities.path("[JAVA_HOME]", "test.txt"), System.getenv("JAVA_HOME")+"\\test.txt");
}
}

View File

@ -17,7 +17,7 @@
<properties>
<hapi_fhir_version>4.1.0</hapi_fhir_version>
<validator_test_case_version>1.0.39-SNAPSHOT</validator_test_case_version>
<validator_test_case_version>1.0.40-SNAPSHOT</validator_test_case_version>
</properties>
<artifactId>org.hl7.fhir.core</artifactId>

View File

@ -11,7 +11,8 @@ echo ..
call mvn versions:set -DnewVersion=%newver%-SNAPSHOT
call git commit -a -m "Release new version"
call git commit -t v%newver% -a -m "Release new version %newver%"
call git push origin master
call "C:\tools\fnr.exe" -dir "C:\work\org.hl7.fhir\build" -fileMask "*.xml" -find "%oldver%-SNAPSHOT" -replace "%newver%-SNAPSHOT" -count 8
call "C:\tools\fnr.exe" -dir "C:\work\org.hl7.fhir\fhir-ig-publisher" -fileMask "*.xml" -find "%oldver%-SNAPSHOT" -replace "%newver%-SNAPSHOT" -count 2