- Timestamp:
- 2007-10-30T13:53:42+01:00 (17 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/Preferences.java
r441 r442 170 170 * in log. 171 171 */ 172 p rotectedvoid save() {172 public void save() { 173 173 try { 174 174 final PrintWriter out = new PrintWriter(new FileWriter(getPreferencesDir() + "preferences"), false); … … 189 189 final BufferedReader in = new BufferedReader(new FileReader(getPreferencesDir()+"preferences")); 190 190 int lineNumber = 0; 191 ArrayList<Integer> errLines = new ArrayList<Integer>(); 191 192 for (String line = in.readLine(); line != null; line = in.readLine(), lineNumber++) { 192 193 final int i = line.indexOf('='); 193 if (i == -1 || i == 0) 194 throw new IOException("Malformed config file at line "+lineNumber); 194 if (i == -1 || i == 0) { 195 errLines.add(lineNumber); 196 continue; 197 } 195 198 properties.put(line.substring(0,i), line.substring(i+1)); 199 } 200 if (!errLines.isEmpty()) { 201 throw new IOException("Malformed config file at lines " + errLines); 196 202 } 197 203 } -
trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r350 r442 101 101 if (!prefDir.exists()) 102 102 prefDir.mkdirs(); 103 104 if (!new File(Main.pref.getPreferencesDir()+"preferences").exists()) { 105 Main.pref.resetToDefault(); 106 } 107 103 108 try { 104 109 if (args.containsKey("reset-preferences")) { … … 109 114 } catch (final IOException e1) { 110 115 e1.printStackTrace(); 111 JOptionPane.showMessageDialog(null, "Preferences could not be loaded. Writing default preference file to "+pref.getPreferencesDir()+"preferences"); 112 Main.pref.resetToDefault(); 116 String backup = Main.pref.getPreferencesDir() + "preferences.bak"; 117 JOptionPane.showMessageDialog(null, "Preferences file had errors. Making backup of old one to " + backup); 118 new File(Main.pref.getPreferencesDir() + "preferences").renameTo(new File(backup)); 119 Main.pref.save(); 113 120 } 114 121
Note:
See TracChangeset
for help on using the changeset viewer.