Mercurial > hg > Members > anatofuz > growsync
changeset 15:0dc44ee170b4
mkdir
author | anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 03 Jan 2021 08:46:08 +0900 |
parents | 1e21b0c29775 |
children | b391a8ad61de |
files | cmd_edit.go util.go version.go |
diffstat | 3 files changed, 13 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/cmd_edit.go Thu Dec 17 11:12:04 2020 +0900 +++ b/cmd_edit.go Sun Jan 03 08:46:08 2021 +0900 @@ -14,8 +14,6 @@ type editCmd struct{} -const layout string = "2006/01/02" - func (pc *editCmd) name() string { return "edit" } @@ -42,6 +40,8 @@ localFilePATH := filepath.Join(config.LocalRoot, growiPATH+".md") + mkdir(localFilePATH) + var beforeTime time.Time alreadyExistsFile := existsFile(localFilePATH) @@ -79,6 +79,8 @@ return client.UpdatePage(growiPATH, localFilePATH) } +const layout string = "2006/01/02" + func createNewDailyMarkdownPATH(dailyPATH string) string { now := time.Now() return filepath.Join(dailyPATH, now.Format(layout))
--- a/util.go Thu Dec 17 11:12:04 2020 +0900 +++ b/util.go Sun Jan 03 08:46:08 2021 +0900 @@ -32,3 +32,11 @@ } return !info.IsDir() } + +func mkdir(targetPATH string) error { + dirName := filepath.Dir(targetPATH) + if _, err := os.Stat(dirName); os.IsNotExist(err) { + return os.MkdirAll(dirName, 0755) + } + return nil +}