home *** CD-ROM | disk | FTP | other *** search
-
- /*
- ┌────────────────────────────────────────────────────────────────────────────┐
- │copyfile.dmo │
- │Copy a file to another file. Use the command line for the file names │
- │Synopsis: │
- │ Copyfile <source> <destin> <Options> │
- │ │
- └────────────────────────────────────────────────────────────────────────────┘
- */
-
- #define BUFSIZE 32767
-
- #if DEBUG
- int wsource,wdestin;
- char *wbuf,*malloc();
- int wnum;
- #endif
-
- main(argc,argv)
- int argc;
- char **argv;
- {
-
- #if ! DEBUG
- int wsource,wdestin;
- char *wbuf,*malloc();
- int wnum;
- #endif
-
- if ((wbuf = malloc(BUFSIZE)) == 0) {
- printf("\nUnable to allocate memory for copy");
- exit(1);
- }
-
- if (argc < 3) {
- printf("\nUsage COPYFILE <source> <destin> <options>");
- exit(1);
- }
-
- wsource = jzopnfil(argv[1],0);
- wdestin = jzcrtfil(argv[2],0);
-
- if ((wsource == -1) || (wdestin == -1)) {
- printf("\nError on Open/Create File. Aborting...");
- exit(1);
- }
-
- do {
- wnum = jzredfil(wsource,wbuf,BUFSIZE); /* read into buffer */
- if (wnum)
- jzwrtfil(wdestin,wbuf,wnum); /* write only the number read */
- } while (wnum);
-
- jzclsfil(wdestin);
- jzclsfil(wsource);
- }
-
-