home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / amiga / misc / 13406 < prev    next >
Encoding:
Text File  |  1992-09-03  |  2.3 KB  |  89 lines

  1. Path: sparky!uunet!mcsun!corton!enst!ulysse!meduse!jeannet
  2. From: jeannet@meduse.enst.fr (Olivier Jeannet)
  3. Newsgroups: comp.sys.amiga.misc
  4. Subject: Re: Splitting and joining large files like gcc2.2.2
  5. Message-ID: <2508@ulysse.enst.fr>
  6. Date: 3 Sep 92 15:07:51 GMT
  7. References: <26AUG199218353578@vx9000.weber.edu>
  8. Sender: news@ulysse.enst.fr
  9. Organization: Telecom Paris, France
  10. Lines: 77
  11.  
  12. In article <26AUG199218353578@vx9000.weber.edu>, alewis@vx9000.weber.edu (ALEWIS) writes:
  13. > I'm sure there's an easy way to do this, but I can't figure it out.
  14. > I'm trying to get the latest gcc which comes in a 3M+ file.  I don't have the
  15. > modem option so I was hoping to find a join for the Amiga that would work with
  16. > files split on a SUN, NeXT, or DOS machine.  I am unable to compile my own
  17. > versions on the source machines, so the source files at wuarchive won't help.
  18. > Any suggestions?
  19.  
  20. I wrote the following program to split a file in 2 or more files.
  21. You use it like that:
  22. "split gcc2.2.2.lha gcc_part"
  23. and you will get the following files : gcc_part1, gcc_part2, etc..
  24. I use this program to copy the files to MS-DOS 720K disks and when I copy the
  25. files back to an amiga, I just have to
  26. "join gcc_part1 gcc_part2 [..] as gcc2.2.2.lha"
  27.  
  28. My program is badly written but it works.
  29.  
  30. ------ beginning of split.c ------
  31.  
  32. #include <stdio.h>
  33.  
  34. #define FLOPPYSIZE (1425*512)
  35. /* a 720K MS-DOS can hold a maximum of 729600 bytes */
  36.  
  37. main(argc,argv)
  38. int argc;
  39. char *argv[];
  40. {
  41.  
  42. FILE *in,*out;
  43. char filename[120],ext[2];
  44. int c;
  45.  
  46. long int count=0;
  47. int filenum=1;
  48.  
  49. if (argc != 3) {
  50.   fputs("usage: split source destination\n",stderr);
  51.   exit(0);
  52. }
  53.  
  54. if (!(in=fopen(argv[1],"rb"))) {
  55.   fprintf(stderr,"unable to open '%s'",argv[1]);
  56.   exit(0);
  57. }
  58.  
  59. strcpy(filename,argv[2]);
  60. ext[0]=(char)filenum+48; ext[1]='\0';    /* 48 = ASCII value of '0' */
  61. strcat(filename,ext);
  62.  
  63. if (!(out=fopen(filename,"wb"))) {
  64.   fprintf(stderr,"unable to open '%s'",filename);
  65.   exit(0);
  66. }
  67.  
  68. while ((c=getc(in)) != EOF) {
  69.   putc(c,out);
  70.   ++count;
  71.   if (!(count % FLOPPYSIZE)) {
  72.     fclose(out);
  73.     ++filenum;
  74.     strcpy(filename,argv[2]);
  75.     ext[0]=(char)filenum+48; ext[1]='\0';
  76.     strcat(filename,ext);
  77.     if (!(out=fopen(filename,"wb"))) {
  78.       fprintf(stderr,"unable to open '%s'",filename);
  79.       exit(0);
  80.     }
  81.   }
  82. }
  83.  
  84. } /* end of main() */
  85.  
  86. ------ end of split.c ------
  87.