I wrote one too. not elegant, but works.
32_split.cpp:
#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <sstream>
#include <cstring>
#include <string>
#include <cstdlib>
using namespace std;
static char Fajl[600000];
int ok=0;
//funkcija koja daje duzinu fajla
const int file_length(const char * f)
{
long m;
ifstream file (f, ios::in|ios::binary);
file.seekg (0, ios::end);
m = file.tellg();
file.close();
return m;
}
// MAIN
int main()
{
ofstream SaveFileODD("odd.bin", ios_base::out | ios::binary); // Izlazni fajl
ofstream SaveFileEVEN("even.bin", ios_base::out | ios::binary); // Izlazni fajl
const int filesize=file_length("rom_all.bin");
ifstream OpenFile("rom_all.bin", ios::binary); // citanje 1.BIN
for(int t=0; t < filesize; ++t) OpenFile.get(Fajl[t]);
OpenFile.close();
for(int t=0; t < filesize; t+=4) SaveFileODD << Fajl[t] << Fajl[t+1];
for(int t=0; t < filesize; t+=4) SaveFileODD << Fajl[t] << Fajl[t+1];
SaveFileODD.close();
for(int t=2; t < filesize; t+=4) SaveFileEVEN << Fajl[t] << Fajl[t+1];
for(int t=2; t < filesize; t+=4) SaveFileEVEN << Fajl[t] << Fajl[t+1];
SaveFileEVEN.close();
cout << "Done! "; cin.get();
}
byteswap.cpp
#include
#include
#include
#include
#include
#include
#include
using namespace std;
static char Fajl[1100000];
int ok=0;
//funkcija koja daje duzinu fajla
const int file_length(const char * f)
{
long m;
ifstream file (f, ios::in|ios::binary);
file.seekg (0, ios::end);
m = file.tellg();
file.close();
return m;
}
// MAIN
int main()
{
ofstream SaveFileODD("swapped.bin", ios_base::out | ios::binary); // Izlazni fajl
const int filesize=file_length("toswap.bin");
ifstream OpenFile("toswap.bin", ios::binary); // citanje 1.BIN
for(int t=0; t < filesize; ++t) OpenFile.get(Fajl[t]);
OpenFile.close();
for(int t=0; t < filesize; t+=2) SaveFileODD << Fajl[t+1] << Fajl[t];
SaveFileODD.close();
cout << "Done! "; cin.get();
}