Skip to content

Commit 2d367e7

Browse files
matthijskooijmanfacchinm
authored andcommitted
Allow .cpp files named after the primary .ino file
This limitation was added a long time ago, when the build system did not cope with this. The current build system handles this situation just fine, so this limitation can be lifted.
1 parent c5c3a77 commit 2d367e7

File tree

1 file changed

+0
-35
lines changed

1 file changed

+0
-35
lines changed

app/src/processing/app/SketchController.java

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -208,28 +208,6 @@ protected void nameCode(String newName) {
208208
}
209209
}
210210

211-
// In Arduino, don't allow a .cpp file with the same name as the sketch,
212-
// because the sketch is concatenated into a file with that name as part
213-
// of the build process.
214-
if (newName.equals(sketch.getName() + ".cpp")) {
215-
Base.showMessage(tr("Error"),
216-
tr("You can't have a .cpp file with the same name as the sketch."));
217-
return;
218-
}
219-
220-
if (renamingCode && current.isPrimary()) {
221-
for (SketchFile file : sketch.getFiles()) {
222-
if (sanitaryName.equalsIgnoreCase(file.getBaseName()) &&
223-
file.isExtension("cpp")) {
224-
Base.showMessage(tr("Error"),
225-
I18n.format(tr("You can't rename the sketch to \"{0}\"\n"
226-
+ "because the sketch already has a .cpp file with that name."),
227-
sanitaryName));
228-
return;
229-
}
230-
}
231-
}
232-
233211

234212
File newFile = new File(sketch.getFolder(), newName);
235213
// if (newFile.exists()) { // yay! users will try anything
@@ -560,19 +538,6 @@ protected boolean saveAs() throws IOException {
560538

561539
File newFolder = new File(newParentDir, newName);
562540

563-
// make sure there doesn't exist a .cpp file with that name already
564-
// but ignore this situation for the first tab, since it's probably being
565-
// resaved (with the same name) to another location/folder.
566-
for (SketchFile file : sketch.getFiles()) {
567-
if (!file.isPrimary() && newName.equalsIgnoreCase(file.getBaseName())) {
568-
Base.showMessage(tr("Error"),
569-
I18n.format(tr("You can't save the sketch as \"{0}\"\n" +
570-
"because the sketch already has a file with that name."), newName
571-
));
572-
return false;
573-
}
574-
}
575-
576541
// check if the paths are identical
577542
if (newFolder.equals(sketch.getFolder())) {
578543
// just use "save" here instead, because the user will have received a

0 commit comments

Comments
 (0)