Skip to content

Commit

Permalink
Merge pull request #2866 from ControlSystemStudio/Bugfix-FilepathsOnW…
Browse files Browse the repository at this point in the history
…indows

CSSTUDIO-2076 Bugfix: add a leading forward slash and replace backslashes in file-paths with forward slashes in `DisplayInfo.forModel()`
  • Loading branch information
abrahamwolk authored Nov 17, 2023
2 parents 4c1e214 + 380151a commit 1d3a946
Showing 1 changed file with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLEncoder;
import java.util.Locale;
import java.util.logging.Level;

import org.csstudio.display.builder.model.DisplayModel;
Expand Down Expand Up @@ -112,7 +113,26 @@ private static String basename(final String path)
*/
public static DisplayInfo forModel(final DisplayModel model)
{
return new DisplayInfo(model.getUserData(DisplayModel.USER_DATA_INPUT_FILE),
String path;
{
String userDataInputFile = model.getUserData(DisplayModel.USER_DATA_INPUT_FILE);
String userDataInputFile_lowerCase = userDataInputFile.toLowerCase(Locale.ROOT);
if ( !userDataInputFile_lowerCase.startsWith("/")
&& !userDataInputFile_lowerCase.startsWith("examples:")
&& !userDataInputFile_lowerCase.startsWith("file:")
&& !userDataInputFile_lowerCase.startsWith("http:")
&& !userDataInputFile_lowerCase.startsWith("https:")
&& !userDataInputFile_lowerCase.startsWith("ftp:")
&& !userDataInputFile_lowerCase.startsWith("jar:")) {
// Add leading '/' and replace occurrences of '\' by '/' in the file path on Windows:
path = "/" + userDataInputFile.replace('\\', '/');
}
else {
path = userDataInputFile;
}
}

return new DisplayInfo(path,
model.getDisplayName(),
model.propMacros().getValue(),
false);
Expand Down

0 comments on commit 1d3a946

Please sign in to comment.