mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-13 19:51:25 +01:00
Error conditions for some mkdirs methods
This commit is contained in:
parent
11c52c4228
commit
2476c75b6c
@ -16,8 +16,10 @@ import com.djrapitops.plan.utilities.file.FileUtil;
|
|||||||
import com.djrapitops.plugin.api.Check;
|
import com.djrapitops.plugin.api.Check;
|
||||||
import com.djrapitops.plugin.api.utility.log.Log;
|
import com.djrapitops.plugin.api.utility.log.Log;
|
||||||
import com.djrapitops.plugin.task.RunnableFactory;
|
import com.djrapitops.plugin.task.RunnableFactory;
|
||||||
|
import com.djrapitops.plugin.utilities.Verify;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -91,7 +93,8 @@ public class HtmlExport extends SpecificExport {
|
|||||||
List<String> lines = Arrays.asList(html.split("\n"));
|
List<String> lines = Arrays.asList(html.split("\n"));
|
||||||
|
|
||||||
File htmlLocation = new File(outputFolder, "players");
|
File htmlLocation = new File(outputFolder, "players");
|
||||||
htmlLocation.mkdirs();
|
Verify.isTrue(htmlLocation.exists() && htmlLocation.isDirectory() || htmlLocation.mkdirs(),
|
||||||
|
() -> new FileNotFoundException("Output folder could not be created at" + htmlLocation.getAbsolutePath()));
|
||||||
File exportFile = new File(htmlLocation, "index.html");
|
File exportFile = new File(htmlLocation, "index.html");
|
||||||
export(exportFile, lines);
|
export(exportFile, lines);
|
||||||
}
|
}
|
||||||
@ -148,7 +151,8 @@ public class HtmlExport extends SpecificExport {
|
|||||||
.replace("${defaultTheme}", Theme.getValue(ThemeVal.THEME_DEFAULT));
|
.replace("${defaultTheme}", Theme.getValue(ThemeVal.THEME_DEFAULT));
|
||||||
List<String> lines = Arrays.asList(demo.split("\n"));
|
List<String> lines = Arrays.asList(demo.split("\n"));
|
||||||
File outputFolder = new File(this.outputFolder, "js");
|
File outputFolder = new File(this.outputFolder, "js");
|
||||||
outputFolder.mkdirs();
|
Verify.isTrue(outputFolder.exists() && outputFolder.isDirectory() || outputFolder.mkdirs(),
|
||||||
|
() -> new FileNotFoundException("Output folder could not be created at" + outputFolder.getAbsolutePath()));
|
||||||
export(new File(outputFolder, "demo.js"), lines);
|
export(new File(outputFolder, "demo.js"), lines);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.toLog(this.getClass(), e);
|
Log.toLog(this.getClass(), e);
|
||||||
@ -189,7 +193,9 @@ public class HtmlExport extends SpecificExport {
|
|||||||
List<String> lines = FileUtil.lines(plugin, new File(plugin.getDataFolder(), possibleFile), resource);
|
List<String> lines = FileUtil.lines(plugin, new File(plugin.getDataFolder(), possibleFile), resource);
|
||||||
String outputFile = possibleFile.replace("web/", "");
|
String outputFile = possibleFile.replace("web/", "");
|
||||||
File to = new File(outputFolder, outputFile);
|
File to = new File(outputFolder, outputFile);
|
||||||
to.getParentFile().mkdirs();
|
File locationFolder = to.getParentFile();
|
||||||
|
Verify.isTrue(locationFolder.exists() && locationFolder.isDirectory() || locationFolder.mkdirs(),
|
||||||
|
() -> new FileNotFoundException("Output folder could not be created at" + locationFolder.getAbsolutePath()));
|
||||||
if (to.exists()) {
|
if (to.exists()) {
|
||||||
Files.delete(to.toPath());
|
Files.delete(to.toPath());
|
||||||
if (!to.createNewFile()) {
|
if (!to.createNewFile()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user