#include <iostream>
#include <sys/stat.h>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#define max_F 65535
#define max_Char 256
#define file_Size 1024
using namespace std;
class pad_Files
{
private:
size_t* length_Buffer;
char *old_file,*new_file;
char *base;
struct stat file_Value;
void rand_Char(char *text1)
{
int i;
for(i=0;i<max_F;i++)
{
text1[i]=(char)rand()%max_Char+1;
text1[i]=text1[i]^(char)rand()%max_Char+1;
}
}
char *read_File(char *filename)
{
int file;
char *result;
file=open(filename,O_RDONLY);
fstat(file,&file_Value);
*length_Buffer=file_Value.st_size;
result=new char[*length_Buffer];
read(file,result,*length_Buffer);
close(file);
return result;
}
public:
pad_Files(char *file1,char *file2)
{
int file;
memset(base,0,max_F);
old_file=file1;
new_file=file2;
base=read_File(old_file);
rand_Char(base);
file=open(new_file,O_WRONLY | O_CREAT);
write(file,(char*)&length_Buffer,sizeof(length_Buffer));
write(file,base,*length_Buffer);
close(file);
}
};
int main(int argc, char **argv)
{
srand(time(NULL));
pad_Files p_File("file1.txt","file2.txt");
return 0;
}
Brak komentarzy:
Prześlij komentarz