3 Copies one file to another. */
9 main (int argc
, char *argv
[])
15 printf ("usage: cp OLD NEW\n");
19 /* Open input file. */
20 in_fd
= open (argv
[1]);
23 printf ("%s: open failed\n", argv
[1]);
27 /* Create and open output file. */
28 if (!create (argv
[2], filesize (in_fd
)))
30 printf ("%s: create failed\n", argv
[2]);
33 out_fd
= open (argv
[2]);
36 printf ("%s: open failed\n", argv
[2]);
44 int bytes_read
= read (in_fd
, buffer
, sizeof buffer
);
47 if (write (out_fd
, buffer
, bytes_read
) != bytes_read
)
49 printf ("%s: write failed\n", argv
[2]);