Drodzy Moi.
Poszukuje kogoś, kto jest obeznany z kompilowaniem programów pod Windows. Mam se takie oto coś:
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
typedef struct {
long position;
long length;
} reference;
int get_filesize(ifstream * where) {
where->seekg (0, ios::end);
int length = where->tellg();
where->seekg (0, ios::beg);
return(length);
}
void dump_lsb(reference toDump, ofstream * where) {
int pos = toDump.position, len = toDump.length;
// first dump position
*where << (char)pos << (char)(pos>>8) << (char)(pos >> 16) << (char)(pos >> 24);
// then length;
*where << (char)len << (char)(len>>8) << (char)(len>>16) << (char)(len>>24);
}
void dump_file(ifstream * source, ofstream * dest) {
char transition;
while (source->read(&transition, 1))
(*dest) << transition;
}
int main(int argc, char * * argv) {
// First get the number of files to include.
int num_files = argc - 2;
if (num_files <= 0) {
cout << "Usage: " << argv[0] << " output.cat files ..." << endl;
return(-1);
}
// Now get their sizes and complete the headers.
// Would Be Nice: use lists to get around files that won't open.
vector<reference> headers(num_files);
vector<ifstream *> files(num_files);
int counter;
headers[0].position = sizeof(reference)*headers.size();
for (counter = 0; counter < num_files; counter++) {
cout << argv[2+counter] << endl;
files[counter] = new ifstream(argv[2+counter]);
if (!(*files[counter])) {
cerr << "Could not open " << argv[2+counter];
cout << " for reading." << endl;
return(-1);
}
headers[counter].length = get_filesize(files[counter]);
if (counter < num_files-1)
headers[counter+1].position = headers[counter].position
+ headers[counter].length;
}
// -- Dump.
ofstream x(argv[1], ios::trunc);
ifstream infile();
if (!x) {
cerr << "Could not open " << argv[2] << " for writing." << endl;
return(-1);
}
// First the headers.
for (counter = 0; counter < num_files; counter++)
dump_lsb(headers[counter], &x);
// then the contents.
for (counter = 0; counter < num_files; counter++) {
dump_file(files[counter], &x);
files[counter] -> close();
}
}
i chcę, żeby z tego wyszedł plik binarny do uruchomienia pod Windows.
Co to jest? To programik, który (teoretycznie) potrafi spakować sample typu WAV do pliku o rozszerzeniu .CAT. Ten format był użyty w blaszakowej wersji UFO ENEMY UNKNOWN oraz paru innych grach MicroProse.
Pomożecie?
Ja programistą nie jestem i nie umiem tego...
Ostatnia aktualizacja: 07.11.2012 02:07:19 przez OSH