mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-18 12:54:25 +01:00
Fixed wrong sketch structure check in Editor and SketchData.
This commit is contained in:
parent
612f4c926f
commit
7c58be397b
@ -2124,15 +2124,14 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
* Second stage of open, occurs after having checked to see if the
|
||||
* modifications (if any) to the previous sketch need to be saved.
|
||||
*/
|
||||
protected boolean handleOpenInternal(File file) {
|
||||
protected boolean handleOpenInternal(File sketchFile) {
|
||||
// check to make sure that this .pde file is
|
||||
// in a folder of the same name
|
||||
String fileName = file.getName();
|
||||
String fileName = sketchFile.getName();
|
||||
|
||||
if (SketchData.checkSketchFile(file)) {
|
||||
// no beef with this guy
|
||||
File file = SketchData.checkSketchFile(sketchFile);
|
||||
|
||||
} else if (!fileName.endsWith(".ino") && !fileName.endsWith(".pde")) {
|
||||
if ((file == null) && !fileName.endsWith(".ino") && !fileName.endsWith(".pde")) {
|
||||
Base.showWarning(_("Bad file selected"),
|
||||
_("Arduino can only open its own sketches\n" +
|
||||
"and other files ending in .ino or .pde"), null);
|
||||
|
@ -52,7 +52,7 @@ public class SketchData {
|
||||
//System.out.println("sketch dir is " + folder);
|
||||
}
|
||||
|
||||
static public boolean checkSketchFile(File file) {
|
||||
static public File checkSketchFile(File file) {
|
||||
// check to make sure that this .pde file is
|
||||
// in a folder of the same name
|
||||
String fileName = file.getName();
|
||||
@ -63,7 +63,16 @@ public class SketchData {
|
||||
String inoName = parentName + ".ino";
|
||||
File altInoFile = new File(parent, inoName);
|
||||
|
||||
return pdeName.equals(fileName) || inoName.equals(fileName) || altPdeFile.exists() || altInoFile.exists();
|
||||
if (pdeName.equals(fileName) || inoName.equals(fileName))
|
||||
return file;
|
||||
|
||||
if (altPdeFile.exists())
|
||||
return altPdeFile;
|
||||
|
||||
if (altInoFile.exists())
|
||||
return altInoFile;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -83,7 +83,7 @@ public class Compiler implements MessageConsumer {
|
||||
private ProgressListener progressListener;
|
||||
|
||||
static public String build(SketchData data, String buildPath, File tempBuildFolder, ProgressListener progListener, boolean verbose) throws RunnerException {
|
||||
if (!SketchData.checkSketchFile(data.getPrimaryFile()))
|
||||
if (SketchData.checkSketchFile(data.getPrimaryFile()) == null)
|
||||
BaseNoGui.showError(_("Bad file selected"),
|
||||
_("Bad sketch primary file or bad sketck directory structure"), null);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user