GetTmpContentPath returns the path to the temporary file containing content being added or edited
(ctx context.DnoteCtx)
| 31 | // GetTmpContentPath returns the path to the temporary file containing |
| 32 | // content being added or edited |
| 33 | func GetTmpContentPath(ctx context.DnoteCtx) (string, error) { |
| 34 | for i := 0; ; i++ { |
| 35 | filename := fmt.Sprintf("%s_%d.%s", consts.TmpContentFileBase, i, consts.TmpContentFileExt) |
| 36 | candidate := fmt.Sprintf("%s/%s", ctx.Paths.Cache, filename) |
| 37 | |
| 38 | ok, err := utils.FileExists(candidate) |
| 39 | if err != nil { |
| 40 | return "", errors.Wrapf(err, "checking if file exists at %s", candidate) |
| 41 | } |
| 42 | if !ok { |
| 43 | return candidate, nil |
| 44 | } |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | // getEditorCommand returns the system's editor command with appropriate flags, |
| 49 | // if necessary, to make the command wait until editor is close to exit. |