void fg_readfile( char *fname, vector<unsigned char> &out )
{
FILE *f;
out.clear();
unsigned char chr[2] = { 0, 0 };
int c = 0, a, s;
f = fopen(fname, "r");
fseek (f , 0 , SEEK_END);
s = ftell(f);
for( a = 0; a < s; a++ )
{
fseek (f, a, SEEK_SET); // removing this file will end somehow
// really quick
fread(chr, 1,1, f);
out.push_back(chr[0]);
}
fclose(f);
}
void fg_savefile( char *fname, const vector<unsigned char> in )
{
FILE *f;
unsigned char chr[2] = { 0, 0 };
unsigned int a;
f = fopen(fname, "w");
for( a = 0; a < in.size(); a++ )
{
// fseek (f, a, SEEK_SET);
chr[0] = in[a];
fwrite( chr, 1, 1, f);
}
fclose(f);
} |