removeTmpFiles recursively finds and removes .tmp files.
(root string)
| 167 | |
| 168 | // removeTmpFiles recursively finds and removes .tmp files. |
| 169 | func removeTmpFiles(root string) error { |
| 170 | return filepath.Walk(root, func(path string, info os.FileInfo, err error) error { |
| 171 | switch { |
| 172 | case err != nil: |
| 173 | return nil // skip errored files |
| 174 | case info.IsDir(): |
| 175 | return nil // skip directories |
| 176 | case !strings.HasSuffix(path, ".tmp"): |
| 177 | return nil // skip non-temp files |
| 178 | default: |
| 179 | return os.Remove(path) |
| 180 | } |
| 181 | }) |
| 182 | } |
| 183 | |
| 184 | // LTXDir returns the path to an LTX directory. |
| 185 | func LTXDir(root string) string { |