mirror of https://github.com/noisymime/Arduino.git
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
|
* Second stage of open, occurs after having checked to see if the
|
||||||
* modifications (if any) to the previous sketch need to be saved.
|
* 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
|
// check to make sure that this .pde file is
|
||||||
// in a folder of the same name
|
// in a folder of the same name
|
||||||
String fileName = file.getName();
|
String fileName = sketchFile.getName();
|
||||||
|
|
||||||
if (SketchData.checkSketchFile(file)) {
|
File file = SketchData.checkSketchFile(sketchFile);
|
||||||
// no beef with this guy
|
|
||||||
|
|
||||||
} else if (!fileName.endsWith(".ino") && !fileName.endsWith(".pde")) {
|
if ((file == null) && !fileName.endsWith(".ino") && !fileName.endsWith(".pde")) {
|
||||||
Base.showWarning(_("Bad file selected"),
|
Base.showWarning(_("Bad file selected"),
|
||||||
_("Arduino can only open its own sketches\n" +
|
_("Arduino can only open its own sketches\n" +
|
||||||
"and other files ending in .ino or .pde"), null);
|
"and other files ending in .ino or .pde"), null);
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class SketchData {
|
||||||
//System.out.println("sketch dir is " + folder);
|
//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
|
// check to make sure that this .pde file is
|
||||||
// in a folder of the same name
|
// in a folder of the same name
|
||||||
String fileName = file.getName();
|
String fileName = file.getName();
|
||||||
|
@ -63,7 +63,16 @@ public class SketchData {
|
||||||
String inoName = parentName + ".ino";
|
String inoName = parentName + ".ino";
|
||||||
File altInoFile = new File(parent, inoName);
|
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;
|
private ProgressListener progressListener;
|
||||||
|
|
||||||
static public String build(SketchData data, String buildPath, File tempBuildFolder, ProgressListener progListener, boolean verbose) throws RunnerException {
|
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"),
|
BaseNoGui.showError(_("Bad file selected"),
|
||||||
_("Bad sketch primary file or bad sketck directory structure"), null);
|
_("Bad sketch primary file or bad sketck directory structure"), null);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue