6 "github.com/mjl-/mox/mlog"
7 "github.com/mjl-/mox/mox-"
10// CreateMessageTemp creates a temporary file, e.g. for delivery. The is created in
11// subdirectory tmp of the data directory, so the file is on the same file system
12// as the accounts directory, so renaming files can succeed. The caller is
13// responsible for closing and possibly removing the file. The caller should ensure
14// the contents of the file are synced to disk before attempting to deliver the
16func CreateMessageTemp(log mlog.Log, pattern string) (*os.File, error) {
17 dir := mox.DataDirPath("tmp")
18 os.MkdirAll(dir, 0770)
19 f, err := os.CreateTemp(dir, pattern)
26 log.Check(xerr, "closing temp message file after chmod error")