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
This commit is contained in:
Matthijs Kooijman 2015-12-11 19:18:19 +01:00 committed by Martino Facchin
parent 76be212f23
commit f3d8ba219f
2 changed files with 9 additions and 49 deletions

View File

@ -642,12 +642,6 @@ public class Sketch {
Base.copyDir(data.getDataFolder(), newDataFolder); Base.copyDir(data.getDataFolder(), newDataFolder);
} }
// re-copy the code folder
if (data.getCodeFolder().exists()) {
File newCodeFolder = new File(newFolder, "code");
Base.copyDir(data.getCodeFolder(), newCodeFolder);
}
// save the main tab with its new name // save the main tab with its new name
File newFile = new File(newFolder, newName + ".ino"); File newFile = new File(newFolder, newName + ".ino");
data.getCode(0).saveAs(newFile); data.getCode(0).saveAs(newFile);
@ -729,29 +723,17 @@ public class Sketch {
String codeExtension = null; String codeExtension = null;
boolean replacement = false; boolean replacement = false;
// if the file appears to be code related, drop it for (String extension : SketchData.EXTENSIONS) {
// into the code folder, instead of the data folder String lower = filename.toLowerCase();
if (filename.toLowerCase().endsWith(".o") || if (lower.endsWith("." + extension)) {
filename.toLowerCase().endsWith(".a") || destFile = new File(data.getFolder(), filename);
filename.toLowerCase().endsWith(".so")) { codeExtension = extension;
//if (!codeFolder.exists()) codeFolder.mkdirs();
prepareCodeFolder();
destFile = new File(data.getCodeFolder(), filename);
} else {
for (String extension : SketchData.EXTENSIONS) {
String lower = filename.toLowerCase();
if (lower.endsWith("." + extension)) {
destFile = new File(data.getFolder(), filename);
codeExtension = extension;
}
}
if (codeExtension == null) {
prepareDataFolder();
destFile = new File(data.getDataFolder(), filename);
} }
} }
if (codeExtension == null) {
prepareDataFolder();
destFile = new File(data.getDataFolder(), filename);
}
// check whether this file already exists // check whether this file already exists
if (destFile.exists()) { if (destFile.exists()) {
@ -1183,18 +1165,6 @@ public class Sketch {
} }
/**
* Create the code folder if it does not exist already. As a convenience,
* it also returns the code folder, since it's likely about to be used.
*/
private File prepareCodeFolder() {
if (!data.getCodeFolder().exists()) {
data.getCodeFolder().mkdirs();
}
return data.getCodeFolder();
}
public SketchCode[] getCodes() { public SketchCode[] getCodes() {
return data.getCodes(); return data.getCodes();
} }

View File

@ -31,11 +31,6 @@ public class SketchData {
*/ */
private File dataFolder; private File dataFolder;
/**
* code folder location for this sketch (may not exist yet)
*/
private File codeFolder;
/** /**
* Name of sketch, which is the name of main file (without .pde or .java * Name of sketch, which is the name of main file (without .pde or .java
* extension) * extension)
@ -72,7 +67,6 @@ public class SketchData {
name = mainFilename.substring(0, mainFilename.length() - suffixLength); name = mainFilename.substring(0, mainFilename.length() - suffixLength);
folder = new File(file.getParent()); folder = new File(file.getParent());
codeFolder = new File(folder, "code");
dataFolder = new File(folder, "data"); dataFolder = new File(folder, "data");
codes = listSketchFiles(true); codes = listSketchFiles(true);
} }
@ -217,8 +211,4 @@ public class SketchData {
public File getDataFolder() { public File getDataFolder() {
return dataFolder; return dataFolder;
} }
public File getCodeFolder() {
return codeFolder;
}
} }