()
| 126 | } |
| 127 | |
| 128 | func (c *Client) newTempFile() (*os.File, error) { |
| 129 | if err := mkdirAll(c.TempDir); err != nil { |
| 130 | return nil, err |
| 131 | } |
| 132 | prefix := fmt.Sprintf("%d.", int(time.Now().Unix())) |
| 133 | f, err := ioutil.TempFile(c.TempDir, prefix) |
| 134 | if err != nil { |
| 135 | return nil, errors.Trace(err) |
| 136 | } |
| 137 | return f, nil |
| 138 | } |
| 139 | |
| 140 | func (c *Client) writeFile(realpath string, data []byte, noexists bool) error { |
| 141 | if noexists { |