Skip to content

Use file passed on command line when using --upload or --verify #10756

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
Closed
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions arduino-core/src/processing/app/Sketch.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class Sketch {
public static final List<String> OTHER_ALLOWED_EXTENSIONS = Arrays.asList("c", "cpp", "h", "hh", "hpp", "s");
public static final List<String> EXTENSIONS = Stream.concat(SKETCH_EXTENSIONS.stream(), OTHER_ALLOWED_EXTENSIONS.stream()).collect(Collectors.toList());

private final File initialFile;

/**
* folder that contains this sketch
*/
Expand Down Expand Up @@ -50,6 +52,7 @@ public int compare(SketchFile x, SketchFile y) {
* Any file inside the sketch directory.
*/
Sketch(File file) throws IOException {
initialFile = file;
folder = file.getParentFile();
files = listSketchFiles(true);
}
Expand Down Expand Up @@ -143,6 +146,13 @@ public int getCodeCount() {
return files.size();
}

/**
* Returns the initial File used to initialize this Sketch
*/
public File getInitialFile() {
return initialFile;
}

public SketchFile[] getFiles() {
return files.toArray(new SketchFile[0]);
}
Expand Down
3 changes: 2 additions & 1 deletion arduino-core/src/processing/app/SketchFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ public SketchFile(Sketch sketch, File file) {
this.sketch = sketch;
this.file = file;
FileUtils.SplitFile split = FileUtils.splitFilename(file);
this.primary = split.basename.equals(sketch.getFolder().getName())
this.primary = (file.equals(sketch.getInitialFile())
|| split.basename.equals(sketch.getFolder().getName()))
&& Sketch.SKETCH_EXTENSIONS.contains(split.extension);
}

Expand Down