home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / extra18 / ctricks / filespli / c_und_p.cpp next >
Encoding:
C/C++ Source or Header  |  1992-01-29  |  1.8 KB  |  83 lines

  1. /* ------------------------------------------------- */
  2. /*                     C&P.CPP                       */
  3. /*        Utility zum Teilen von großen Dateien      */
  4. /*            (c) F.Torzinski & DMV-Verlag           */
  5. /* ------------------------------------------------- */
  6. #include <alloc.h>
  7. #include <stdio.h>
  8. #include <process.h>
  9. #include <iostream.h>
  10.  
  11.          int  f(void);
  12.  
  13. unsigned long n, m, MAX = 362496;
  14.  
  15.          char in[15], out[15];
  16.          char far *buf,far *pb;
  17.          FILE *fi, *fo;
  18.  
  19. /* ------------------------------------------------- */
  20.  
  21. main(int c, char **v)
  22. {
  23.   int e;
  24.  
  25.   if (c == 1) {
  26.     cout << " Aufruf:  c&p   -c\t<= für cut\n"
  27.          << "\t\t-p\t<= für pull together";
  28.     exit(1);
  29.   }
  30.   if ( !(buf = (char *) farmalloc(MAX+1)))
  31.     exit(1);
  32.   cout << "woher (LW:NAME) ";
  33.   cin  >> in;
  34.   cout << "wohin (LW:NAME) ";
  35.   cin  >> out;
  36.   if (*++v[1] == 'c') {
  37.     out[2] = '0';
  38.     if ( !(fi = fopen(in, "rb")))
  39.       exit(2);
  40.     while (e != EOF) {
  41.       out[2]++;
  42.       if ( !(fo = fopen(out, "wb")))
  43.         exit(3);
  44.       e = f();
  45.       fclose(fo);
  46.     }
  47.   }
  48.   else if (*v[1] == 'p') {
  49.     in[2] = '0';
  50.     if ( !(fo = fopen(out, "wb")))
  51.       exit(4);
  52.     while (e != EOF) {
  53.       in[2]++;
  54.       if ( !(fi = fopen(in, "rb")))
  55.         exit(3);
  56.       e = f();
  57.       fclose(fi);
  58.     }
  59.   }
  60. }
  61.  
  62. /* ------------------------------------------------- */
  63. f()
  64. {
  65.   int c = 1;
  66.  
  67.   pb = buf;
  68.   for (n = 0; n < MAX && c != EOF; n++)
  69.     *pb++ = c = fgetc(fi);
  70.   pb = buf;
  71.   if (c == EOF) n--;
  72.   for (m = 0; m < n; m++)
  73.     fputc(*pb++, fo);
  74.   cout << "nächste Disk einlegen";
  75.   getchar();
  76.   return c;
  77. }
  78. /* ------------------------------------------------- */
  79. /*              Ende von C&P.CPP                     */
  80.  
  81.  
  82.  
  83.