Make file directories before saving
This commit is contained in:
parent
4414f3ecc0
commit
2453207d20
1 changed files with 6 additions and 0 deletions
|
@ -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()) {
|
||||||
|
|
Loading…
Reference in a new issue