Skip to content

Commit f3d8ba2

Browse files
matthijskooijmanfacchinm
authored andcommitted
Remove support for a "code" folder in sketches
When adding a file to a sketch (using drag and drop, or the Sketch -> Add file... menu item), .o, .a and .so files would be saved into a "code" subdirectory of the sketch. This seems to be a remnant of processing, where also .dll and .jar files could be added to a sketch to be used. In the Arduino IDE, these code files serve no special purpose, and are not treated specially, so it makes no sense to keep this code around. One implication of this is that when "save as" is used, a "code" subdirectory is no longer copied, which might affect people using this "code" subdirectory for other purposes. Similarly, there is support for a "data" subdirectory, in which all other files (that are not sketch source files) are stored, and which is also copied on "save as". Support for this folder is kept intact, since this appears occasionally used (the ESP8266 project uses it to store and upload additional data files, for example). This change was discussed on the mailing list in the "Anyone using "data" and "code" subdirectories in sketches?" thread: https://groups.google.com/a/arduino.cc/forum/#!msg/developers/zPlraPq55ho/ejrLqITnAgAJ
1 parent 76be212 commit f3d8ba2

File tree

2 files changed

+9
-49
lines changed

2 files changed

+9
-49
lines changed

app/src/processing/app/Sketch.java

Lines changed: 9 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -642,12 +642,6 @@ protected boolean saveAs() throws IOException {
642642
Base.copyDir(data.getDataFolder(), newDataFolder);
643643
}
644644

645-
// re-copy the code folder
646-
if (data.getCodeFolder().exists()) {
647-
File newCodeFolder = new File(newFolder, "code");
648-
Base.copyDir(data.getCodeFolder(), newCodeFolder);
649-
}
650-
651645
// save the main tab with its new name
652646
File newFile = new File(newFolder, newName + ".ino");
653647
data.getCode(0).saveAs(newFile);
@@ -729,29 +723,17 @@ public boolean addFile(File sourceFile) {
729723
String codeExtension = null;
730724
boolean replacement = false;
731725

732-
// if the file appears to be code related, drop it
733-
// into the code folder, instead of the data folder
734-
if (filename.toLowerCase().endsWith(".o") ||
735-
filename.toLowerCase().endsWith(".a") ||
736-
filename.toLowerCase().endsWith(".so")) {
737-
738-
//if (!codeFolder.exists()) codeFolder.mkdirs();
739-
prepareCodeFolder();
740-
destFile = new File(data.getCodeFolder(), filename);
741-
742-
} else {
743-
for (String extension : SketchData.EXTENSIONS) {
744-
String lower = filename.toLowerCase();
745-
if (lower.endsWith("." + extension)) {
746-
destFile = new File(data.getFolder(), filename);
747-
codeExtension = extension;
748-
}
749-
}
750-
if (codeExtension == null) {
751-
prepareDataFolder();
752-
destFile = new File(data.getDataFolder(), filename);
726+
for (String extension : SketchData.EXTENSIONS) {
727+
String lower = filename.toLowerCase();
728+
if (lower.endsWith("." + extension)) {
729+
destFile = new File(data.getFolder(), filename);
730+
codeExtension = extension;
753731
}
754732
}
733+
if (codeExtension == null) {
734+
prepareDataFolder();
735+
destFile = new File(data.getDataFolder(), filename);
736+
}
755737

756738
// check whether this file already exists
757739
if (destFile.exists()) {
@@ -1183,18 +1165,6 @@ private File prepareDataFolder() {
11831165
}
11841166

11851167

1186-
/**
1187-
* Create the code folder if it does not exist already. As a convenience,
1188-
* it also returns the code folder, since it's likely about to be used.
1189-
*/
1190-
private File prepareCodeFolder() {
1191-
if (!data.getCodeFolder().exists()) {
1192-
data.getCodeFolder().mkdirs();
1193-
}
1194-
return data.getCodeFolder();
1195-
}
1196-
1197-
11981168
public SketchCode[] getCodes() {
11991169
return data.getCodes();
12001170
}

arduino-core/src/processing/app/SketchData.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ public class SketchData {
3131
*/
3232
private File dataFolder;
3333

34-
/**
35-
* code folder location for this sketch (may not exist yet)
36-
*/
37-
private File codeFolder;
38-
3934
/**
4035
* Name of sketch, which is the name of main file (without .pde or .java
4136
* extension)
@@ -72,7 +67,6 @@ public int compare(SketchCode x, SketchCode y) {
7267
name = mainFilename.substring(0, mainFilename.length() - suffixLength);
7368

7469
folder = new File(file.getParent());
75-
codeFolder = new File(folder, "code");
7670
dataFolder = new File(folder, "data");
7771
codes = listSketchFiles(true);
7872
}
@@ -217,8 +211,4 @@ public File getFolder() {
217211
public File getDataFolder() {
218212
return dataFolder;
219213
}
220-
221-
public File getCodeFolder() {
222-
return codeFolder;
223-
}
224214
}

0 commit comments

Comments
 (0)