|
28 | 28 | import java.io.InputStreamReader; |
29 | 29 | import java.io.IOException; |
30 | 30 |
|
| 31 | +import java.nio.file.Files; |
| 32 | +import java.nio.file.StandardCopyOption; |
| 33 | + |
31 | 34 | import java.text.SimpleDateFormat; |
32 | 35 | import java.util.Date; |
33 | 36 | import java.lang.reflect.Field; |
@@ -260,6 +263,7 @@ private void createAndUpload(){ |
260 | 263 | String dataPath = dataFolder.getAbsolutePath(); |
261 | 264 | String toolPath = tool.getAbsolutePath(); |
262 | 265 | String sketchName = editor.getSketch().getName(); |
| 266 | + String sketchFldr = editor.getSketch().getFolder(); |
263 | 267 | String imagePath = getBuildFolderPath(editor.getSketch()) + "\\" + sketchName + ".spiffs.bin"; |
264 | 268 | String resetMethod = BaseNoGui.getBoardPreferences().get("upload.resetmethod"); |
265 | 269 | String uploadSpeed = BaseNoGui.getBoardPreferences().get("upload.speed"); |
@@ -294,6 +298,21 @@ private void createAndUpload(){ |
294 | 298 | editor.statusError("SPIFFS Create Failed!"); |
295 | 299 | return; |
296 | 300 | } |
| 301 | + |
| 302 | + title = "SPIFFS Copy"; |
| 303 | + message = "Would you like a copy of the SPIFFS image in your project folder?"; |
| 304 | + |
| 305 | + if(JOptionPane.showOptionDialog(null, message, title, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[1]) == JOptionPane.YES_OPTION){ |
| 306 | + File source = new File(imagePath); |
| 307 | + File dest = new File(sketchFldr + "\\" + sketchName + ".spiffs.bin"); |
| 308 | + try { |
| 309 | + Files.copy(source.toPath(), dest.toPath(), StandardCopyOption.REPLACE_EXISTING); |
| 310 | + System.out.println("Copied SPIFFS image"); |
| 311 | + } catch (IOException e) { |
| 312 | + System.out.println(e); |
| 313 | + editor.statusError("Copy SPIFFS image failed"); |
| 314 | + } |
| 315 | + } |
297 | 316 |
|
298 | 317 | editor.statusNotice("SPIFFS Uploading Image..."); |
299 | 318 | System.out.println("[SPIFFS] upload : "+imagePath); |
|
0 commit comments