Skip to content

Commit a07a9ff

Browse files
matthijskooijmanfacchinm
authored andcommitted
Move SketchController.prepareDataFolder() to Sketch
1 parent a4e2e80 commit a07a9ff

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

app/src/processing/app/SketchController.java

+1-11
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ public boolean addFile(File sourceFile) {
704704
if (FileUtils.hasExtension(sourceFile, Sketch.EXTENSIONS)) {
705705
destFile = new File(sketch.getFolder(), filename);
706706
} else {
707-
prepareDataFolder();
707+
sketch.prepareDataFolder();
708708
destFile = new File(sketch.getDataFolder(), filename);
709709
isData = true;
710710
}
@@ -1044,16 +1044,6 @@ private boolean sketchFilesAreReadOnly() {
10441044

10451045
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10461046

1047-
/**
1048-
* Create the data folder if it does not exist already. As a convenience,
1049-
* it also returns the data folder, since it's likely about to be used.
1050-
*/
1051-
private File prepareDataFolder() {
1052-
if (!sketch.getDataFolder().exists()) {
1053-
sketch.getDataFolder().mkdirs();
1054-
}
1055-
return sketch.getDataFolder();
1056-
}
10571047

10581048

10591049
private void setUntitled(boolean u) {

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

+12
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,18 @@ private List<SketchCode> listSketchFiles(boolean showWarnings) throws IOExceptio
140140
return new ArrayList<>(result);
141141
}
142142

143+
/**
144+
* Create the data folder if it does not exist already. As a
145+
* convenience, it also returns the data folder, since it's likely
146+
* about to be used.
147+
*/
148+
public File prepareDataFolder() {
149+
if (!dataFolder.exists()) {
150+
dataFolder.mkdirs();
151+
}
152+
return dataFolder;
153+
}
154+
143155
public void save() throws IOException {
144156
for (SketchCode code : getCodes()) {
145157
if (code.isModified())

0 commit comments

Comments
 (0)