MCPcopy Index your code
hub / github.com/arduino/Arduino / createNewUntitled

Method createNewUntitled

app/src/processing/app/Base.java:721–791  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

719 };
720
721 protected File createNewUntitled() throws IOException {
722 File newbieDir = null;
723 String newbieName = null;
724
725 // In 0126, untitled sketches will begin in the temp folder,
726 // and then moved to a new location because Save will default to Save As.
727 File sketchbookDir = BaseNoGui.getSketchbookFolder();
728 File newbieParentDir = untitledFolder;
729
730 // Use a generic name like sketch_031008a, the date plus a char
731 int index = 0;
732 //SimpleDateFormat formatter = new SimpleDateFormat("yyMMdd");
733 //SimpleDateFormat formatter = new SimpleDateFormat("MMMdd");
734 //String purty = formatter.format(new Date()).toLowerCase();
735 Calendar cal = Calendar.getInstance();
736 int day = cal.get(Calendar.DAY_OF_MONTH); // 1..31
737 int month = cal.get(Calendar.MONTH); // 0..11
738 String purty = months[month] + PApplet.nf(day, 2);
739
740 do {
741 if (index == 26*26) {
742 // In 0166, avoid running past zz by sending people outdoors.
743 if (!breakTime) {
744 showWarning(tr("Time for a Break"),
745 tr("You've reached the limit for auto naming of new sketches\n" +
746 "for the day. How about going for a walk instead?"), null);
747 breakTime = true;
748 } else {
749 showWarning(tr("Sunshine"),
750 tr("No really, time for some fresh air for you."), null);
751 }
752 return null;
753 }
754
755 int multiples = index / 26;
756
757 if(multiples > 0){
758 newbieName = ((char) ('a' + (multiples-1))) + "" + ((char) ('a' + (index % 26))) + "";
759 }else{
760 newbieName = ((char) ('a' + index)) + "";
761 }
762 newbieName = "sketch_" + purty + newbieName;
763 newbieDir = new File(newbieParentDir, newbieName);
764 index++;
765 // Make sure it's not in the temp folder *and* it's not in the sketchbook
766 } while (newbieDir.exists() || new File(sketchbookDir, newbieName).exists());
767
768 // Make the directory for the new sketch
769 newbieDir.mkdirs();
770
771 // Make an empty pde file
772 File newbieFile = new File(newbieDir, newbieName + ".ino");
773 if (!newbieFile.createNewFile()) {
774 throw new IOException();
775 }
776
777 // Initialize the pde file with the BareMinimum sketch.
778 // Apply user-defined tab settings.

Callers 1

handleNewMethod · 0.95

Calls 12

getSketchbookFolderMethod · 0.95
nfMethod · 0.95
showWarningMethod · 0.95
readFileToStringMethod · 0.95
getContentFileMethod · 0.95
getBooleanMethod · 0.95
getIntegerMethod · 0.95
writeStringToFileMethod · 0.95
trMethod · 0.80
replaceAllMethod · 0.80
getMethod · 0.65
existsMethod · 0.45

Tested by

no test coverage detected