Stopping you from renaming the main / first sketch file (.pde) if it contains a .cpp file with the new name.

This commit is contained in:
David A. Mellis 2010-01-28 21:19:53 +00:00
parent a59900692a
commit a5b9d31134
1 changed files with 13 additions and 0 deletions

View File

@ -407,6 +407,19 @@ public class Sketch {
"You can't have a .cpp file with the same name as the sketch."); "You can't have a .cpp file with the same name as the sketch.");
return; return;
} }
if (currentIndex == 0) {
for (int i = 1; i < codeCount; i++) {
if (sanitaryName.equalsIgnoreCase(code[i].getPrettyName()) &&
code[i].getExtension().equalsIgnoreCase("cpp")) {
Base.showMessage("Nope",
"You can't rename the sketch to \"" + sanitaryName + "\"\n" +
"because the sketch already has a .cpp file with that name.");
return;
}
}
}
File newFile = new File(folder, newName); File newFile = new File(folder, newName);
// if (newFile.exists()) { // yay! users will try anything // if (newFile.exists()) { // yay! users will try anything