Skip to content

Commit 07e21cf

Browse files
committed
Fix bug with symbol files not being closed.
1 parent 38f7efb commit 07e21cf

File tree

1 file changed

+62
-81
lines changed

1 file changed

+62
-81
lines changed

app/src/processing/app/Base.java

Lines changed: 62 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -2984,93 +2984,74 @@ static public void replaceFileContents(String fileName, String newFileName, Stri
29842984
}
29852985

29862986
static public void installIseSymbol(String libFileName, String catFileName, File symbolDir, String symbols[]) {
2987-
BufferedReader sourceSymbol = null;
2988-
PrintWriter libFile = null;
2989-
PrintWriter catFile = null;
2990-
PrintWriter linuxSymbol = null;
2991-
String symbolName, libPath;
2987+
// BufferedReader sourceSymbol = null;
2988+
// PrintWriter libFile = null;
2989+
// PrintWriter catFile = null;
2990+
// PrintWriter linuxSymbol = null;
2991+
// String symbolName, libPath;
29922992

29932993
if (symbols.length > 0){
29942994
try {
29952995

29962996
//Create an empty edif file in the directory so linux will automatically add the path to the symbols
2997-
// if (Base.isLinux()){
2998-
File edifFile = new File(symbolDir + "/include_symbols.edif");
2999-
if (!edifFile.exists())
3000-
new FileOutputStream(edifFile).close();
3001-
// }
3002-
3003-
libFile = new PrintWriter(new FileWriter(libFileName, true));
3004-
catFile = new PrintWriter(new FileWriter(catFileName, true));
3005-
libPath = new File(libFileName).getParent();
3006-
3007-
3008-
String line;
3009-
3010-
catFile.append("\"." + getFileNameWithoutExtension(symbolDir) + "\"\n{\n");
3011-
for (String symbol : symbols) {
3012-
//showMessage("Test", symbol);
3013-
sourceSymbol = new BufferedReader(new FileReader(symbolDir + "/" + symbol));
3014-
symbolName = getFileNameWithoutExtension(new File(symbol));
3015-
// if (Base.isLinux())
3016-
// linuxSymbol = new PrintWriter(new FileWriter(libPath + "/" + symbol , false));
3017-
3018-
//Append the symbol to the end of the end of the lib file
3019-
while ((line = sourceSymbol.readLine()) != null) {
3020-
//line = line.replace("\\u00", ""); //remove any null characters
3021-
libFile.append(line +"\n");
3022-
// if (Base.isLinux())
3023-
// linuxSymbol.write(line + "\n");
3024-
}
3025-
//libFile.append("\0"); //add null character to the end.
3026-
3027-
//Add the symbol to the cat file
3028-
catFile.append("\"" + symbolName + "\"\n");
3029-
3030-
//Close linuxSymbol
3031-
// if (Base.isLinux()) {
3032-
// if(linuxSymbol != null)
3033-
// linuxSymbol.close();
2997+
File edifFile = new File(symbolDir + "/include_symbols.edif");
2998+
if (!edifFile.exists())
2999+
new FileOutputStream(edifFile).close();
3000+
} catch (IOException e) {
3001+
return;
3002+
}
3003+
}
3004+
//Since discovering that adding an edif file to a directory adds the symbols to the path - the lib and cat files are no longer needed!
3005+
// libFile = new PrintWriter(new FileWriter(libFileName, true));
3006+
// catFile = new PrintWriter(new FileWriter(catFileName, true));
3007+
// libPath = new File(libFileName).getParent();
3008+
//
3009+
//
3010+
// String line;
3011+
//
3012+
// catFile.append("\"." + getFileNameWithoutExtension(symbolDir) + "\"\n{\n");
3013+
// for (String symbol : symbols) {
3014+
// sourceSymbol = new BufferedReader(new FileReader(symbolDir + "/" + symbol));
3015+
// symbolName = getFileNameWithoutExtension(new File(symbol));
3016+
//
3017+
// //Append the symbol to the end of the end of the lib file
3018+
// while ((line = sourceSymbol.readLine()) != null) {
3019+
// libFile.append(line +"\n");
30343020
// }
3035-
3036-
}
3037-
3038-
catFile.append("}\n");
3039-
3040-
} catch (Exception e) {
3041-
return;
3042-
} finally {
3043-
try {
3044-
if(sourceSymbol != null){
3045-
sourceSymbol.close();
3046-
}
3047-
} catch (IOException e) {
3048-
//
3049-
}
3050-
try {
3051-
if(libFile != null){
3052-
//libFile.append("\0"); //add null character to the end.
3053-
libFile.close();
3054-
}
3055-
} catch (Exception e) {
3056-
//
3057-
}
3058-
try {
3059-
if(catFile != null)
3060-
catFile.close();
3061-
} catch (Exception e) {
3062-
//
3063-
}
3064-
// try {
3065-
// if (Base.isLinux()){
3066-
// if(linuxSymbol != null)
3067-
// linuxSymbol.close();
3068-
// }
3069-
// } catch (Exception e) {
3070-
// //
3071-
// }
3072-
}
3073-
}
3021+
//
3022+
// //Add the symbol to the cat file
3023+
// catFile.append("\"" + symbolName + "\"\n");
3024+
//
3025+
//
3026+
// }
3027+
//
3028+
// catFile.append("}\n");
3029+
//
3030+
// } catch (Exception e) {
3031+
// return;
3032+
// } finally {
3033+
// try {
3034+
// if(sourceSymbol != null){
3035+
// sourceSymbol.close();
3036+
// }
3037+
// } catch (IOException e) {
3038+
// //
3039+
// }
3040+
// try {
3041+
// if(libFile != null){
3042+
// libFile.close();
3043+
// }
3044+
// } catch (Exception e) {
3045+
// //
3046+
// }
3047+
// try {
3048+
// if(catFile != null)
3049+
// catFile.close();
3050+
// } catch (Exception e) {
3051+
// //
3052+
// }
3053+
// }
3054+
// }
30743055

30753056
}
30763057

0 commit comments

Comments
 (0)