Skip to content

Commit 4c2fca6

Browse files
Pieter12345cmaglie
authored andcommitted
Replace some FileUtils calls with direct methods
Not wrapping these calls in FileUtils methods makes the code cleaner and easier to understand (FileUtils is very poorly documented, whereas direct calls contain proper documentation).
1 parent e2d2998 commit 4c2fca6

File tree

3 files changed

+9
-16
lines changed

3 files changed

+9
-16
lines changed

app/src/processing/app/Base.java

+2-9
Original file line numberDiff line numberDiff line change
@@ -1691,19 +1691,12 @@ public int compare(File file, File file2) {
16911691
});
16921692

16931693
boolean ifound = false;
1694-
16951694
for (File subfolder : files) {
1696-
if (FileUtils.isSCCSOrHiddenFile(subfolder)) {
1697-
continue;
1698-
}
1699-
1700-
if (!subfolder.isDirectory()) continue;
1701-
1702-
if (addSketchesSubmenu(menu, subfolder.getName(), subfolder)) {
1695+
if (!FileUtils.isSCCSOrHiddenFile(subfolder) && subfolder.isDirectory()
1696+
&& addSketchesSubmenu(menu, subfolder.getName(), subfolder)) {
17031697
ifound = true;
17041698
}
17051699
}
1706-
17071700
return ifound;
17081701
}
17091702

arduino-core/src/cc/arduino/packages/uploaders/MergeSketchWithBooloader.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@
2929

3030
package cc.arduino.packages.uploaders;
3131

32-
import processing.app.helpers.FileUtils;
33-
3432
import java.io.File;
3533
import java.io.FileWriter;
3634
import java.io.IOException;
35+
import java.nio.charset.StandardCharsets;
36+
import java.nio.file.Files;
3737
import java.util.List;
3838

3939
public class MergeSketchWithBooloader {
4040

4141
public void merge(File sketch, File bootloader) throws IOException {
42-
List<String> mergedSketch = FileUtils.readFileToListOfStrings(sketch);
42+
List<String> mergedSketch = Files.readAllLines(sketch.toPath(), StandardCharsets.UTF_8);
4343
mergedSketch.remove(mergedSketch.size() - 1);
44-
mergedSketch.addAll(FileUtils.readFileToListOfStrings(bootloader));
44+
mergedSketch.addAll(Files.readAllLines(bootloader.toPath(), StandardCharsets.UTF_8));
4545

4646
FileWriter writer = null;
4747
try {

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -485,8 +485,8 @@ static public void initPackages() throws Exception {
485485
} catch (JsonProcessingException | SignatureVerificationFailedException e) {
486486
File indexFile = indexer.getIndexFile(Constants.DEFAULT_INDEX_FILE_NAME);
487487
File indexSignatureFile = indexer.getIndexFile(Constants.DEFAULT_INDEX_FILE_NAME + ".sig");
488-
FileUtils.deleteIfExists(indexFile);
489-
FileUtils.deleteIfExists(indexSignatureFile);
488+
indexFile.delete();
489+
indexSignatureFile.delete();
490490
throw e;
491491
}
492492
indexer.syncWithFilesystem();
@@ -502,7 +502,7 @@ static public void initPackages() throws Exception {
502502
librariesIndexer.parseIndex();
503503
} catch (JsonProcessingException e) {
504504
File librariesIndexFile = librariesIndexer.getIndexFile();
505-
FileUtils.deleteIfExists(librariesIndexFile);
505+
librariesIndexFile.delete();
506506
}
507507

508508
if (discoveryManager == null) {

0 commit comments

Comments
 (0)