MCPcopy Index your code
hub / github.com/processing/processing / save

Method save

app/src/processing/app/Preferences.java:212–254  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

210
211
212 static public void save() {
213 // On startup it'll be null, don't worry about it. It's trying to update
214 // the prefs for the open sketch before Preferences.init() has been called.
215 if (preferencesFile != null) {
216 try {
217 File dir = preferencesFile.getParentFile();
218 File preferencesTemp = File.createTempFile("preferences", ".txt", dir);
219 preferencesTemp.setWritable(true, false);
220
221 // Fix for 0163 to properly use Unicode when writing preferences.txt
222 PrintWriter writer = PApplet.createWriter(preferencesTemp);
223
224 String[] keyList = table.keySet().toArray(new String[table.size()]);
225 // Sorting is really helpful for debugging, diffing, and finding keys
226 keyList = PApplet.sort(keyList);
227 for (String key : keyList) {
228 writer.println(key + "=" + table.get(key)); //$NON-NLS-1$
229 }
230 writer.flush();
231 writer.close();
232
233 // Rename preferences.txt to preferences.old
234 File oldPreferences = new File(dir, "preferences.old");
235 if (oldPreferences.exists()) {
236 if (!oldPreferences.delete()) {
237 throw new IOException("Could not delete preferences.old");
238 }
239 }
240 if (preferencesFile.exists() &&
241 !preferencesFile.renameTo(oldPreferences)) {
242 throw new IOException("Could not replace preferences.old");
243 }
244 // Make the temporary file into the real preferences
245 if (!preferencesTemp.renameTo(preferencesFile)) {
246 throw new IOException("Could not move preferences file into place");
247 }
248
249 } catch (IOException e) {
250 Messages.showWarning("Preferences",
251 "Could not save the Preferences file.", e);
252 }
253 }
254 }
255
256
257 // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Callers 8

startServerMethod · 0.95
initMethod · 0.95
handleCloseMethod · 0.95
handleQuitMethod · 0.95
handleCloseMethod · 0.95
updateExpandedMethod · 0.95
handleOpenInternalMethod · 0.95
handleCloseMethod · 0.95

Calls 11

createWriterMethod · 0.95
sortMethod · 0.95
showWarningMethod · 0.95
createTempFileMethod · 0.80
deleteMethod · 0.80
renameToMethod · 0.80
getMethod · 0.65
sizeMethod · 0.45
printlnMethod · 0.45
flushMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected