Skip to content

Commit 9276d08

Browse files
committed
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 6364e3e commit 9276d08

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
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-2
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,16 @@
3434
import java.io.File;
3535
import java.io.FileWriter;
3636
import java.io.IOException;
37+
import java.nio.charset.StandardCharsets;
38+
import java.nio.file.Files;
3739
import java.util.List;
3840

3941
public class MergeSketchWithBooloader {
4042

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

4648
FileWriter writer = null;
4749
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)