Make file directories before saving

This commit is contained in:
William Brawner 2018-09-04 17:39:16 -05:00 committed by William Brawner
parent 4414f3ecc0
commit 2453207d20

View file

@ -23,6 +23,7 @@ public class MarkdownFile {
private String name; private String name;
private String path; private String path;
private String content; private String content;
public MarkdownFile(String name, String path, String content) { public MarkdownFile(String name, String path, String content) {
this.name = name; this.name = name;
if (path == null || path.isEmpty()) { if (path == null || path.isEmpty()) {
@ -147,6 +148,11 @@ public class MarkdownFile {
} }
File markdownFile = new File(path); File markdownFile = new File(path);
File parentFile = markdownFile.getParentFile();
if (!parentFile.exists() && !parentFile.mkdirs()) {
return false;
}
if (!markdownFile.exists()) { if (!markdownFile.exists()) {
try { try {
if (!markdownFile.createNewFile()) { if (!markdownFile.createNewFile()) {