Move `SketchController.prepareDataFolder()` to Sketch

This commit is contained in:
Matthijs Kooijman 2015-12-17 13:00:47 +01:00 committed by Martino Facchin
parent a4e2e80c1c
commit a07a9ff895
2 changed files with 13 additions and 11 deletions

View File

@ -704,7 +704,7 @@ public class SketchController {
if (FileUtils.hasExtension(sourceFile, Sketch.EXTENSIONS)) {
destFile = new File(sketch.getFolder(), filename);
} else {
prepareDataFolder();
sketch.prepareDataFolder();
destFile = new File(sketch.getDataFolder(), filename);
isData = true;
}
@ -1044,16 +1044,6 @@ public class SketchController {
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
/**
* Create the data folder if it does not exist already. As a convenience,
* it also returns the data folder, since it's likely about to be used.
*/
private File prepareDataFolder() {
if (!sketch.getDataFolder().exists()) {
sketch.getDataFolder().mkdirs();
}
return sketch.getDataFolder();
}
private void setUntitled(boolean u) {

View File

@ -140,6 +140,18 @@ public class Sketch {
return new ArrayList<>(result);
}
/**
* Create the data folder if it does not exist already. As a
* convenience, it also returns the data folder, since it's likely
* about to be used.
*/
public File prepareDataFolder() {
if (!dataFolder.exists()) {
dataFolder.mkdirs();
}
return dataFolder;
}
public void save() throws IOException {
for (SketchCode code : getCodes()) {
if (code.isModified())