From 88855cb93903a65f8958db4f5b99fc1d64fe58ac Mon Sep 17 00:00:00 2001 From: Kalmer Apinis Date: Wed, 26 Mar 2014 14:10:23 +0100 Subject: [PATCH] File.separator not useful for cygwin --- src/g2html/Config.java | 2 +- src/g2html/Loc.java | 2 +- src/g2html/Result.java | 8 ++++---- src/g2html/ResultStats.java | 2 +- src/g2html/Structure.java | 2 +- src/g2html/Warning.java | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/g2html/Config.java b/src/g2html/Config.java index f44af6d..8f247bb 100644 --- a/src/g2html/Config.java +++ b/src/g2html/Config.java @@ -72,7 +72,7 @@ public static void load(String[] args) { // returns the input dot file for a given C file, and function public static File getFunDotFile(String path, String fun) { - path = path.replaceAll(Pattern.quote(File.separator),"%2F"); + path = path.replaceAll("/", "%2F"); File f = new File(new File(new File(conf.getCfgDir()), path), fun + ".dot"); return f; } diff --git a/src/g2html/Loc.java b/src/g2html/Loc.java index 79ad05a..b92b878 100644 --- a/src/g2html/Loc.java +++ b/src/g2html/Loc.java @@ -18,7 +18,7 @@ static public void parseLocNode(XMLStreamReader parser, Result res, ResultStats String id = parser.getAttributeValue("", "id"); // compute the file-id from the full path - String shortFile = file.replaceAll(Pattern.quote(File.separator),"%2F"); + String shortFile = file.replaceAll("/", "%2F"); // look up the database for the file FileStats fileStats = resultStats.getStats(shortFile); diff --git a/src/g2html/Result.java b/src/g2html/Result.java index 0d0bc09..ec778bd 100644 --- a/src/g2html/Result.java +++ b/src/g2html/Result.java @@ -73,6 +73,7 @@ private static void copyFromJar(String f,File t) throws IOException{ // generic file copy public static void copyFile( File from, File to ) throws IOException { + System.out.printf("copy resource from '%s' to '%s'\n", from, to); if ( !to.exists() ) { to.createNewFile(); } try ( @@ -85,13 +86,12 @@ public static void copyFile( File from, File to ) throws IOException { // copy a file either form the jar or from a special resources directory public static void copyResource(String f, File to) throws IOException { - String basePath = File.separator + "resources" + File.separator; try { /* try jar first ... */ - copyFromJar(basePath + f, to); + copyFromJar("/resources/" + f, to); } catch (IOException e){ /* .. no? This means that we are debugging in an IDE? */ - copyFile(new File(".."+basePath+f), to); + copyFile(new File(".."+File.separator + "resources" + File.separator+f), to); } } @@ -105,7 +105,7 @@ public Result(String resDir) throws IOException { // return a listing file to be created public File getListingFile(String path) { - path = path.replaceAll(Pattern.quote(File.separator),"%2F"); + path = path.replaceAll("/","%2F"); File f = new File(filDir, path+".xml"); return f; } diff --git a/src/g2html/ResultStats.java b/src/g2html/ResultStats.java index 5adf953..bc79230 100644 --- a/src/g2html/ResultStats.java +++ b/src/g2html/ResultStats.java @@ -59,7 +59,7 @@ public void printReport(Result r) continue; // write the file-name report.writeStartElement("file"); - report.writeAttribute("name", file.replaceAll("%2F", Matcher.quoteReplacement(File.separator))); + report.writeAttribute("name", file.replaceAll("%2F", "/")); // for each function for (String fun : fm.get(file).getFunctions()){ diff --git a/src/g2html/Structure.java b/src/g2html/Structure.java index 1e87a14..6a97cbe 100644 --- a/src/g2html/Structure.java +++ b/src/g2html/Structure.java @@ -14,7 +14,7 @@ public static void parseFileNode(XMLStreamReader parser, ResultStats resultStats throws XMLStreamException { // get basic information - String name = parser.getAttributeValue("", "path").replaceAll(Pattern.quote(File.separator),"%2F");; + String name = parser.getAttributeValue("", "path").replaceAll("/", "%2F");; String fun = ""; // parse the file and diff --git a/src/g2html/Warning.java b/src/g2html/Warning.java index 2876459..6f28f87 100644 --- a/src/g2html/Warning.java +++ b/src/g2html/Warning.java @@ -44,7 +44,7 @@ static public void parseWarningNode(XMLStreamReader parser, Result res, ResultSt readcc.getLocalName()=="text"){ String path = readcc.getAttributeValue("","file"); String line = readcc.getAttributeValue("","line"); - String shortFile = path.replaceAll(Pattern.quote(File.separator),"%2F");; + String shortFile = path.replaceAll("/", "%2F"); resultStats.getStats(shortFile).addWarning(id,Integer.valueOf(line)); }