#include <fstream.h>
#include <iostream.h>
#include <cstdlib>
#include <conio.h>
#include <stdio.h>
void splitter() {
char ch;
char nn;
char contt;
char target[100];
char *result;
char stringa[100];
int bytes;
int valore;
int o = 0;
int cont = -1;
int resto = 1;
int f=0;
system("cls");
cout << "Splitt vers 1.0 Autore MyLamer88 - Copriright 2006 -" << endl << "============================================" << endl << endl << endl;
printf("Inserisci il percorso ed il nome del file da splittare (compresa estenzione): ");
result = _cgets( target );
fstream infile;
infile.open(result, ios::in|ios::binary);
while (!infile.eof()) {
infile.get(contt);
cont++;
}
infile.close();
infile.open(result, ios::in|ios::binary);
cout << endl << "Inserisci la dimensione dei file da creare per lo split (Espressa in KB): ";
cin >> valore;
bytes = valore*1024;
resto = cont%bytes;
cout << endl << "Inserisci la destinazione ed il nome dei file da salvare per lo split (senza estenzione): ";
cin >> stringa;
while (stringa[o] != 0) {
o++;
}
stringa[o]='1' + f;
o++;
stringa[o]='.';
o++;
stringa[o]='m';
o++;
stringa[o]='l';
o++;
stringa[o]='r';
o++;
stringa[o]=0;
nn = '1' + f;
cout << "Creazione del file N° " << nn << ": Attendere...";
while (!infile.eof()) {
cout << endl << endl << "============================================" << endl << endl;
fstream outfile;
outfile.open(stringa, ios::out|ios::binary);
o=0;
f++;
while (stringa[o] != 0) {
o++;
}
o -= 5;
stringa[o]='1' + f;
if (cont == resto) {
for (int i=1; i<=resto; i++) {
infile.get(ch);
outfile.put(ch);
}
cont = 1;
cout << endl << endl << "============================================" << endl << endl;
}
else if (cont == 1) {
infile.get(ch);
cout << endl << endl << "============================================" << endl << endl;
}
else {
for (int i=1; i<=bytes; i++) {
infile.get(ch);
outfile.put(ch);
}
cout << endl << endl << "============================================" << endl << endl;
cont -= bytes;
}
nn = '1' + f;
cout << "Creazione del file N° " << nn << ": Attendere...";
outfile.close();
}
o = 0;
while (stringa[o] != 0) {
o++;
}
o -= 5;
stringa[o]='.';
o++;
stringa[o]='s';
o++;
stringa[o]='e';
o++;
stringa[o]='t';
o++;
stringa[o]=0;
fstream outfile;
outfile.open(stringa, ios::out);
ch = '0' + f;
outfile.put(ch);
cout << endl << endl << "============================================" << endl << endl;
cout << endl << endl << "Operazione eseguita con successo.";
}
void assembl() {
char ch;
char target[100];
char stringa[100];
char *result;
int numm = 0;
int o = 0;
system("cls");
cout << "Splitt vers 1.0 Autore MyLamer88 - Copriright 2006 -" << endl << "============================================" << endl << endl << endl;
cout << endl << endl;
printf("\nInserisci il percorso ed il nome che si desidera dare al file finale (compresa estenzione): ");
result = _cgets( stringa );
fstream outfile;
outfile.open(result, ios::out|ios::binary);
cout << endl << "Inserisci il percorso, il nome e l'estenzione del file settaggi ('nomefile'.set) per l'assemblaggio: ";
cin >> target;
cout << endl << endl << "============================================" << endl << endl;
fstream infile;
infile.open(target, ios::in|ios::binary);
infile.get(ch);
numm = ch - '0';
infile.close();
while (target[o] != 0) {
o++;
}
o -= 4;
target[o]='1';
o++;
target[o]='.';
o++;
target[o]='m';
o++;
target[o]='l';
o++;
target[o]='r';
o++;
target[o]= 0;
for (int i = 1; i <= numm - 1; i++) {
o = 0;
while (target[o] != 0) {
o++;
}
o -= 5;
target[o] = '0' + i;
fstream infile;
infile.open(target, ios::in|ios::binary);
while (infile.get(ch)) {
outfile.put(ch);
//cout << ch;
}
infile.close();
}
cout << endl << endl << "============================================" << endl << endl;
cout << "Operazione eseguita con successo.";
cout << endl << endl << "============================================" << endl << endl;
}
void main() {
int num = 2;
cout << "Splitt vers 1.0 Autore MyLamer88 - Copriright 2006 -" << endl << endl << endl << endl;
while (num != 0) {
do {
cout << endl << "============================================" << endl;
cout << "Inserisci '1' per aprire lo splitter; Inserisci '2' per riassemblare un file: Inserisci '0' per uscire: ";
cout << endl << "============================================" << endl;
cout << endl << "N: ";
cin >> num;
cout << endl;
if (num == 1) {
splitter();
}
else if (num == 2) {
assembl();
}
}
while (num != 1 && num != 2 && num != 0);
}
cout << endl << endl;
system("PAUSE");
}