Skip to content

Commit 4ef5699

Browse files
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 5e35929 commit 4ef5699

File tree

2 files changed

+9
-49
lines changed

2 files changed

+9
-49
lines changed

app/src/processing/app/Sketch.java

+9-39
Original file line numberDiff line numberDiff line change
@@ -643,12 +643,6 @@ protected boolean saveAs() throws IOException {
643643
Base.copyDir(data.getDataFolder(), newDataFolder);
644644
}
645645

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

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

757739
// check whether this file already exists
758740
if (destFile.exists()) {
@@ -1175,18 +1157,6 @@ private File prepareDataFolder() {
11751157
}
11761158

11771159

1178-
/**
1179-
* Create the code folder if it does not exist already. As a convenience,
1180-
* it also returns the code folder, since it's likely about to be used.
1181-
*/
1182-
private File prepareCodeFolder() {
1183-
if (!data.getCodeFolder().exists()) {
1184-
data.getCodeFolder().mkdirs();
1185-
}
1186-
return data.getCodeFolder();
1187-
}
1188-
1189-
11901160
public SketchCode[] getCodes() {
11911161
return data.getCodes();
11921162
}

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

-10
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)