MCPcopy Index your code
hub / github.com/benfry/processing4 / classicFolder

Method classicFolder

app/src/processing/app/SketchName.java:55–103  ·  view source on GitHub ↗

Use a generic name like sketch_031008a, the date plus a char.

(File parentDir)

Source from the content-addressed store, hash-verified

53 * Use a generic name like sketch_031008a, the date plus a char.
54 */
55 static File classicFolder(File parentDir) {
56 File newbieDir;
57 String newbieName;
58
59 int index = 0;
60 String prefix = Preferences.get("editor.untitled.prefix");
61 String format = Preferences.get("editor.untitled.suffix");
62 String suffix;
63 if (format == null) {
64 // If no format is specified, uses this ancient format
65 Calendar cal = Calendar.getInstance();
66 int day = cal.get(Calendar.DAY_OF_MONTH); // 1..31
67 int month = cal.get(Calendar.MONTH); // 0..11
68 final String[] months = {
69 "jan", "feb", "mar", "apr", "may", "jun",
70 "jul", "aug", "sep", "oct", "nov", "dec"
71 };
72 suffix = months[month] + PApplet.nf(day, 2);
73 } else {
74 SimpleDateFormat formatter = new SimpleDateFormat(format);
75 suffix = formatter.format(new Date());
76 }
77 do {
78 if (index == 26) {
79 // In 0159, avoid running past z by sending people outdoors.
80 if (!breakTime) {
81 Messages.showWarning("Time for a Break",
82 "You've reached the limit for auto naming of new sketches\n" +
83 "for the day. How about going for a walk instead?", null);
84 breakTime = true;
85 } else {
86 Messages.showWarning("Sunshine",
87 "No really, time for some fresh air for you.\n" +
88 "(At a minimum, you'll need to restart Processing.)", null);
89 }
90 return null;
91 }
92 newbieName = prefix + suffix + ((char) ('a' + index));
93 // Also sanitize the name since it might do strange things on
94 // non-English systems that don't use this sort of date format.
95 // https://github.com/processing/processing/issues/322
96 newbieName = Sketch.sanitizeName(newbieName);
97 newbieDir = new File(parentDir, newbieName);
98 index++;
99 // Make sure it's not in the temp folder *and* it's not in the sketchbook
100 } while (newbieDir.exists() || new File(Base.getSketchbookFolder(), newbieName).exists());
101
102 return newbieDir;
103 }
104
105
106 static class WordList {

Callers 1

nextFolderMethod · 0.95

Calls 8

getMethod · 0.95
nfMethod · 0.95
showWarningMethod · 0.95
sanitizeNameMethod · 0.95
getSketchbookFolderMethod · 0.95
getMethod · 0.65
formatMethod · 0.65
getInstanceMethod · 0.45

Tested by

no test coverage detected