(fs billy.Filesystem, name string, data []byte, perm fs.FileMode)
| 1639 | } |
| 1640 | |
| 1641 | func writeFile(fs billy.Filesystem, name string, data []byte, perm fs.FileMode) error { |
| 1642 | f, err := fs.OpenFile(name, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, perm) |
| 1643 | if err != nil { |
| 1644 | return fmt.Errorf("create file: %w", err) |
| 1645 | } |
| 1646 | _, err = f.Write(data) |
| 1647 | if err != nil { |
| 1648 | err = fmt.Errorf("write file: %w", err) |
| 1649 | } |
| 1650 | if err2 := f.Close(); err2 != nil && err == nil { |
| 1651 | err = fmt.Errorf("close file: %w", err2) |
| 1652 | } |
| 1653 | return err |
| 1654 | } |
| 1655 | |
| 1656 | func writeMagicImageFile(fs billy.Filesystem, path string, v any) error { |
| 1657 | file, err := fs.OpenFile(path, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0o644) |
no test coverage detected