mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-19 08:52:15 +01:00
Do not store the sketch name in Sketch
Sketch already stores the sketch folder, and the sketch name should be identical to the folder name. In the case where the filename passed to the sketch constructor is not the primary .ino file (named after the sketch), this will slightly change behaviour. However, the calling code should prevent this from happening, and with the old code, some internal assumptions were probably violated, so this changes makes handling this situation a bit more robust. Since the actual filename passed to Sketch is no longer used, it is no longer required to pass the name of the primary .ino file. At some point, the constructor should probably be changed to accept a folder name instead of a filename, but that would require a lot of changes to trace this back through the code, so this is something for later.
This commit is contained in:
parent
7a73d0b3db
commit
0c62ac8985
@ -25,12 +25,6 @@ public class Sketch {
|
||||
*/
|
||||
private File folder;
|
||||
|
||||
/**
|
||||
* Name of sketch, which is the name of main file (without .pde or .java
|
||||
* extension)
|
||||
*/
|
||||
private String name;
|
||||
|
||||
private List<SketchFile> files = new ArrayList<SketchFile>();
|
||||
|
||||
private static final Comparator<SketchFile> CODE_DOCS_COMPARATOR = new Comparator<SketchFile>() {
|
||||
@ -49,15 +43,9 @@ public class Sketch {
|
||||
* on disk to get populate the list of files in this sketch.
|
||||
*
|
||||
* @param file
|
||||
* The primary file for this sketch.
|
||||
* Any file inside the sketch directory.
|
||||
*/
|
||||
Sketch(File file) throws IOException {
|
||||
// get the name of the sketch by chopping .pde or .java
|
||||
// off of the main file name
|
||||
String mainFilename = primaryFile.getName();
|
||||
int suffixLength = getDefaultExtension().length() + 1;
|
||||
name = mainFilename.substring(0, mainFilename.length() - suffixLength);
|
||||
|
||||
folder = new File(file.getParent());
|
||||
files = listSketchFiles(true);
|
||||
}
|
||||
@ -195,7 +183,7 @@ public class Sketch {
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
return folder.getName();
|
||||
}
|
||||
|
||||
public File getFolder() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user