Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Splitr - Splitr.cpp

Splitr.cpp

Caricato da:
Scarica il programma completo

  1. #include <fstream.h>
  2. #include <iostream.h>
  3. #include <cstdlib>
  4. #include <conio.h>
  5. #include <stdio.h>
  6.  
  7.  
  8. void splitter() {
  9.  
  10.         char ch;
  11.         char nn;
  12.         char contt;
  13.         char target[100];
  14.         char *result;
  15.         char stringa[100];
  16.         int bytes;
  17.         int valore;
  18.         int o = 0;
  19.         int cont = -1;
  20.         int resto = 1;
  21.         int f=0;
  22.  
  23.         system("cls");
  24.         cout << "Splitt vers 1.0 Autore MyLamer88 - Copriright 2006 -" << endl << "============================================" << endl << endl << endl;
  25.  
  26.         printf("Inserisci il percorso ed il nome del file da splittare (compresa estenzione): ");
  27.         result = _cgets( target );
  28.         fstream infile;
  29.         infile.open(result, ios::in|ios::binary);
  30.  
  31.         while (!infile.eof()) {
  32.                 infile.get(contt);
  33.                 cont++;
  34.         }
  35.  
  36.     infile.close();
  37.     infile.open(result, ios::in|ios::binary);
  38.  
  39.     cout << endl << "Inserisci la dimensione dei file da creare per lo split (Espressa in KB): ";
  40.         cin >> valore;
  41.     bytes = valore*1024;
  42.  
  43.         resto = cont%bytes;
  44.         cout << endl << "Inserisci la destinazione ed il nome dei file da salvare per lo split (senza estenzione): ";
  45.         cin >> stringa;
  46.  
  47.                 while (stringa[o] != 0) {
  48.                         o++;
  49.                 }
  50.                 stringa[o]='1' + f;
  51.                 o++;
  52.                 stringa[o]='.';
  53.                 o++;
  54.                 stringa[o]='m';
  55.                 o++;
  56.                 stringa[o]='l';
  57.                 o++;
  58.                 stringa[o]='r';
  59.                 o++;
  60.                 stringa[o]=0;
  61.            
  62.         nn = '1' + f;
  63.                 cout << "Creazione del file N° " << nn << ": Attendere...";
  64.  
  65.         while (!infile.eof()) {
  66.  
  67.                 cout << endl << endl << "============================================" << endl << endl;
  68.  
  69.         fstream outfile;
  70.         outfile.open(stringa, ios::out|ios::binary);
  71.  
  72.                 o=0;
  73.                 f++;
  74.  
  75.                 while (stringa[o] != 0) {
  76.                         o++;
  77.                 }
  78.                 o -= 5;
  79.                 stringa[o]='1' + f;
  80.  
  81.                 if (cont == resto) {
  82.                         for (int i=1; i<=resto; i++) {
  83.                         infile.get(ch);
  84.                         outfile.put(ch);
  85.                         }
  86.                         cont = 1;
  87.                         cout << endl << endl << "============================================" << endl << endl;
  88.                 }
  89.  
  90.                 else if (cont == 1) {
  91.                         infile.get(ch);
  92.                         cout << endl << endl << "============================================" << endl << endl;
  93.                 }
  94.  
  95.                 else {
  96.        
  97.                 for (int i=1; i<=bytes; i++) {
  98.                         infile.get(ch);
  99.                         outfile.put(ch);
  100.                         }
  101.                         cout << endl << endl << "============================================" << endl << endl;
  102.                     cont -= bytes;
  103.                 }
  104.             nn = '1' + f;
  105.                     cout << "Creazione del file N° " << nn << ": Attendere...";
  106.                     outfile.close();
  107.  
  108.         }
  109.            
  110.             o = 0;
  111.             while (stringa[o] != 0) {
  112.                 o++;
  113.                 }
  114.                 o -= 5;
  115.                 stringa[o]='.';
  116.                 o++;
  117.                 stringa[o]='s';
  118.                 o++;
  119.                 stringa[o]='e';
  120.                 o++;
  121.                 stringa[o]='t';
  122.                 o++;
  123.                 stringa[o]=0;
  124.  
  125.         fstream outfile;
  126.         outfile.open(stringa, ios::out);
  127.  
  128.                 ch = '0' + f;
  129.                 outfile.put(ch);
  130.  
  131.  
  132.  
  133.                 cout << endl << endl << "============================================" << endl << endl;
  134.             cout << endl << endl << "Operazione eseguita con successo.";
  135. }
  136.  
  137.  
  138.  
  139. void assembl() {
  140.  
  141.         char ch;
  142.         char target[100];
  143.         char stringa[100];
  144.         char *result;
  145.     int numm = 0;
  146.         int o = 0;
  147.  
  148.     system("cls");
  149.         cout << "Splitt vers 1.0 Autore MyLamer88 - Copriright 2006 -" << endl << "============================================" << endl << endl << endl;
  150.  
  151.         cout << endl << endl;
  152.         printf("\nInserisci il percorso ed il nome che si desidera dare al file finale (compresa estenzione): ");
  153.         result = _cgets( stringa );
  154.        
  155.         fstream outfile;
  156.         outfile.open(result, ios::out|ios::binary);
  157.  
  158.         cout << endl << "Inserisci il percorso, il nome e l'estenzione del file settaggi ('nomefile'.set) per l'assemblaggio: ";
  159.         cin >> target;
  160.         cout << endl << endl << "============================================" << endl << endl;
  161.  
  162.                 fstream infile;
  163.                 infile.open(target, ios::in|ios::binary);
  164.                 infile.get(ch);
  165.                 numm = ch - '0';
  166.                 infile.close();
  167.  
  168.         while (target[o] != 0) {
  169.                 o++;
  170.                 }
  171.                 o -= 4;
  172.                 target[o]='1';
  173.                 o++;
  174.                 target[o]='.';
  175.                 o++;
  176.                 target[o]='m';
  177.                 o++;
  178.                 target[o]='l';
  179.                 o++;
  180.                 target[o]='r';
  181.                 o++;
  182.                 target[o]= 0;
  183.  
  184.         for (int i = 1; i <= numm - 1; i++) {
  185.  
  186.                 o = 0;
  187.  
  188.                 while (target[o] != 0) {
  189.                 o++;
  190.                 }
  191.                 o -= 5;
  192.                 target[o] = '0' + i;
  193.  
  194.                 fstream infile;
  195.                 infile.open(target, ios::in|ios::binary);
  196.  
  197.                 while (infile.get(ch)) {
  198.                         outfile.put(ch);
  199.                         //cout << ch;
  200.                 }
  201.  
  202.                 infile.close();
  203.  
  204.         }
  205.  
  206.     cout << endl << endl << "============================================" << endl << endl;
  207.         cout << "Operazione eseguita con successo.";
  208.         cout << endl << endl << "============================================" << endl << endl;
  209. }
  210.  
  211.  
  212.  
  213. void main() {
  214.  
  215.         int num = 2;
  216.     cout << "Splitt vers 1.0 Autore MyLamer88 - Copriright 2006 -" << endl << endl << endl << endl;
  217.  
  218.         while (num != 0) {
  219.        
  220.         do {
  221.  
  222.     cout << endl << "============================================" << endl;
  223.         cout << "Inserisci '1' per aprire lo splitter; Inserisci '2' per riassemblare un file: Inserisci '0' per uscire: ";
  224.         cout << endl << "============================================" << endl;
  225.         cout << endl << "N: ";
  226.         cin >> num;
  227.         cout << endl;
  228.  
  229.                 if (num == 1) {
  230.                         splitter();
  231.                 }
  232.                 else if (num == 2) {
  233.                         assembl();
  234.                 }
  235.  
  236.         }
  237.         while (num != 1 && num != 2 && num != 0);
  238.         }
  239.  
  240.         cout << endl << endl;
  241.         system("PAUSE");
  242.  
  243. }