Skip to content

Commit

Permalink
File.separator not useful for cygwin
Browse files Browse the repository at this point in the history
  • Loading branch information
kalmera committed Mar 26, 2014
1 parent aa29c45 commit 88855cb
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/g2html/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/g2html/Loc.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions src/g2html/Result.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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);
}
}

Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/g2html/ResultStats.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()){
Expand Down
2 changes: 1 addition & 1 deletion src/g2html/Structure.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/g2html/Warning.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down

0 comments on commit 88855cb

Please sign in to comment.