Skip to content

Commit

Permalink
Don't create filenames longer than 255 characters (typetools#6299)
Browse files Browse the repository at this point in the history
  • Loading branch information
mernst authored and wmdietl committed Dec 4, 2023
1 parent 9e858fc commit 3fa39e0
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,7 @@ public String visualizeBlockTransferInputAfter(Block bb, Analysis<V, S, T> analy
*/
protected String dotOutputFileName(UnderlyingAST ast) {
StringBuilder srcLoc = new StringBuilder();
StringBuilder outFile = new StringBuilder(outDir);

outFile.append("/");
StringBuilder outFile = new StringBuilder();

if (ast.getKind() == UnderlyingAST.Kind.ARBITRARY_CODE) {
CFGStatement cfgStatement = (CFGStatement) ast;
Expand Down Expand Up @@ -264,8 +262,13 @@ protected String dotOutputFileName(UnderlyingAST ast) {
}
outFile.append(".dot");

// make path safe for Linux
if (outFile.length() > 255) {
outFile.setLength(255);
}
// make path safe for Windows
String outFileName = outFile.toString().replace("<", "_").replace(">", "");
String outFileBaseName = outFile.toString().replace("<", "_").replace(">", "");
String outFileName = outDir + "/" + outFileBaseName;

generated.put(srcLoc.toString(), outFileName);

Expand Down

0 comments on commit 3fa39e0

Please sign in to comment.