1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-10-21 17:24:39 +00:00

Fixed problem where tmp-folders were not deleted properly. Closes #370

This commit is contained in:
jespergravgaard 2020-05-30 09:30:57 +02:00
parent a99256645a
commit 8d8b14ad5a

View File

@ -3,6 +3,7 @@ package dk.camelot64.kickc.passes;
import dk.camelot64.kickc.asm.*;
import dk.camelot64.kickc.asm.AsmFormat;
import dk.camelot64.kickc.model.CompileError;
import dk.camelot64.kickc.model.InternalError;
import dk.camelot64.kickc.model.Program;
import kickass.KickAssembler;
import kickass.nonasm.c64.CharToPetsciiConverter;
@ -114,6 +115,7 @@ public class Pass5FixLongBranches extends Pass5AsmOptimization {
// Found line number
//getLog().append("Found long branch line number "+contextLineIdx);
if(fixLongBranch(contextLineIdx - 1)) {
removeTmpDir();
return true;
}
}
@ -121,9 +123,25 @@ public class Pass5FixLongBranches extends Pass5AsmOptimization {
}
}
}
removeTmpDir();
return false;
}
private void removeTmpDir() {
// Delete the temporary directory with folders
String[]entries = tmpDir.toFile().list();
for(String s: entries){
File currentFile = new File(tmpDir.toFile(),s);
if(!currentFile.delete()) {
System.err.println("Warning! Cannot delete temporary file "+currentFile.getAbsolutePath());
}
}
if(!tmpDir.toFile().delete()) {
System.err.println("Warning! Cannot delete temporary folder "+tmpDir.toAbsolutePath());
}
}
/**
* Fix a long branch detected at a specific ASM index
*