mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-18 12:54:25 +01:00
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:
parent
76be212f23
commit
f3d8ba219f
@ -642,12 +642,6 @@ public class Sketch {
|
||||
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
|
||||
File newFile = new File(newFolder, newName + ".ino");
|
||||
data.getCode(0).saveAs(newFile);
|
||||
@ -729,29 +723,17 @@ public class Sketch {
|
||||
String codeExtension = null;
|
||||
boolean replacement = false;
|
||||
|
||||
// if the file appears to be code related, drop it
|
||||
// into the code folder, instead of the data folder
|
||||
if (filename.toLowerCase().endsWith(".o") ||
|
||||
filename.toLowerCase().endsWith(".a") ||
|
||||
filename.toLowerCase().endsWith(".so")) {
|
||||
|
||||
//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);
|
||||
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);
|
||||
}
|
||||
|
||||
// check whether this file already 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() {
|
||||
return data.getCodes();
|
||||
}
|
||||
|
@ -31,11 +31,6 @@ public class SketchData {
|
||||
*/
|
||||
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
|
||||
* extension)
|
||||
@ -72,7 +67,6 @@ public class SketchData {
|
||||
name = mainFilename.substring(0, mainFilename.length() - suffixLength);
|
||||
|
||||
folder = new File(file.getParent());
|
||||
codeFolder = new File(folder, "code");
|
||||
dataFolder = new File(folder, "data");
|
||||
codes = listSketchFiles(true);
|
||||
}
|
||||
@ -217,8 +211,4 @@ public class SketchData {
|
||||
public File getDataFolder() {
|
||||
return dataFolder;
|
||||
}
|
||||
|
||||
public File getCodeFolder() {
|
||||
return codeFolder;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user