-
Notifications
You must be signed in to change notification settings - Fork 756
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
17 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
*/ | ||
|
||
/* | ||
* Copyright (c) 2006, 2023, Oracle and/or its affiliates. All rights reserved. | ||
* Copyright (c) 2006, 2024, Oracle and/or its affiliates. All rights reserved. | ||
* Portions Copyright (c) 2019, Chris Fraire <[email protected]>. | ||
*/ | ||
package org.opengrok.indexer.util; | ||
|
@@ -54,6 +54,10 @@ public class CtagsUtil { | |
|
||
public static final String SYSTEM_CTAGS_PROPERTY = "org.opengrok.indexer.analysis.Ctags"; | ||
|
||
/** Private to enforce static. */ | ||
private CtagsUtil() { | ||
} | ||
|
||
/** | ||
* Check that {@code ctags} program exists and is working. | ||
* @param ctagsBinary name of the ctags program or path | ||
|
@@ -163,7 +167,7 @@ public static Set<String> getLanguages(String ctagsBinary) { | |
Set<String> result = new HashSet<>(); | ||
for (String lang : split) { | ||
lang = lang.trim(); | ||
if (lang.length() > 0) { | ||
if (!lang.isEmpty()) { | ||
result.add(lang); | ||
} | ||
} | ||
|
@@ -192,7 +196,7 @@ public static void deleteTempFiles() { | |
continue; | ||
} | ||
|
||
LOGGER.log(Level.FINER, "deleting Ctags temporary files in directory {0}", directoryName); | ||
LOGGER.log(Level.FINER, "deleting Ctags temporary files in directory ''{0}''", directoryName); | ||
deleteTempFiles(directory); | ||
} | ||
} | ||
|
@@ -205,14 +209,18 @@ private static void deleteTempFiles(File directory) { | |
return matcher.find(); | ||
}); | ||
|
||
if (Objects.isNull(files)) { | ||
return; | ||
} | ||
|
||
for (File file : files) { | ||
if (file.isFile() && !file.delete()) { | ||
LOGGER.log(Level.WARNING, "cannot delete file {0}", file); | ||
if (file.isFile()) { | ||
try { | ||
Files.delete(file.toPath()); | ||
} catch (IOException exception) { | ||
LOGGER.log(Level.WARNING, String.format("cannot delete file '%s'", file), exception); | ||
} | ||
} | ||
} | ||
} | ||
|
||
/** Private to enforce static. */ | ||
private CtagsUtil() { | ||
} | ||
} |