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 path;
|
||||
private String content;
|
||||
|
||||
public MarkdownFile(String name, String path, String content) {
|
||||
this.name = name;
|
||||
if (path == null || path.isEmpty()) {
|
||||
|
@ -147,6 +148,11 @@ public class MarkdownFile {
|
|||
}
|
||||
|
||||
File markdownFile = new File(path);
|
||||
File parentFile = markdownFile.getParentFile();
|
||||
if (!parentFile.exists() && !parentFile.mkdirs()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!markdownFile.exists()) {
|
||||
try {
|
||||
if (!markdownFile.createNewFile()) {
|
||||
|
|
Loading…
Reference in a new issue