Skip to content

Bug fix for legacy libs using .pde examples. #4021

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions arduino-core/src/processing/app/packages/LegacyUserLibrary.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,61 @@
import java.io.File;
import java.util.Arrays;
import java.util.List;
import javax.swing.JOptionPane;

public class LegacyUserLibrary extends UserLibrary {

private String name;

public static LegacyUserLibrary create(File libFolder) {

//Check legacy libraries for examples using .pde extensions.
//.pde examples no longer compile as the builder uses a hard coded .ino extension.
File examplesFolder = new File(libFolder, "examples");
boolean hasNotifiedOfPdeExamples = false;

if (examplesFolder.isDirectory()){

File[] dirs = examplesFolder.listFiles();

if (dirs != null){
example_verify_loop: //Label to break out of if the user chooses not to update a library.
for (File childDir : dirs) {

if (childDir.isDirectory()){

File[] sketchFiles = childDir.listFiles();

for (File childFile : sketchFiles) {

if (childFile.isFile()){
if (childFile.getName().endsWith(".pde")){
if (!hasNotifiedOfPdeExamples){ //only prompt once per library.

int msgResult = JOptionPane.showConfirmDialog(
null,
"One or more of the examples in the library \"" + libFolder.getName() + "\" uses a file extension that is no longer compatible with the IDE." +
"\nSketches (and examples) since version 1.0 of the IDE are required to use '.ino' extensions!" +
"\nPrior to version 1.0, the extension used was '.pde'." +
"\nClick yes to update the extensions of these files automatically (contents is not touched).",
libFolder.getName() + " contains out of date examples!",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE);

if (msgResult == 1){
break example_verify_loop;
}
hasNotifiedOfPdeExamples = true;
}
childFile.renameTo(new File(childFile.getPath().replace(".pde", ".ino")));
}
}
}
}
}
}
}

// construct an old style library
LegacyUserLibrary res = new LegacyUserLibrary();
res.setInstalledFolder(libFolder);
Expand Down