- /* The -file argument processing used path() to
- expand filename to absolute path. */
- int file = ct->c_file && ct->c_file[0] == '/';
-
- admonish (NULL, "unable to rename %s %s to %s",
- file ? "file" : "message", outfile, infile);
+ /* Rename didn't work, possibly because of an
+ attempt to rename across filesystems. Try
+ brute force copy. */
+ int old = open (outfile, O_RDONLY);
+ int new =
+ open (infile, O_WRONLY | O_CREAT, m_gmprot ());
+ int i = -1;
+
+ if (old != -1 && new != -1) {
+ char buffer[BUFSIZ];
+
+ while ((i = read (old, buffer, sizeof buffer)) >
+ 0) {
+ if (write (new, buffer, i) != i) {
+ i = -1;
+ break;
+ }
+ }
+ }
+ if (new != -1) close (new);
+ if (old != -1) close (old);