#include <iostream>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/sendfile.h>
using namespace std;
class COPY_SENDF
{
private:
int file_begin;
int file_end;
string name_begin;
string name_end;
struct stat str_stat;
off_t temp_off;
public:
void read(string name1, string name2)
{
name_begin=name1;
name_end=name2;
}
void s_Copy()
{
file_begin=open(name_begin.c_str(),O_RDONLY);
fstat(file_begin,&str_stat);
file_end=open(name_end.c_str(),O_WRONLY | O_CREAT,str_stat.st_mode);
sendfile(file_end,file_begin,&temp_off,str_stat.st_size);
close(file_begin);
close(file_end);
}
};
string write_proc(string name)
{
string result;
result="/proc/"+name;
return result;
}
int main(int argc, char **argv)
{
string info="/home/PROC_DATES";
string files_proc[8]={"filesystems","version","meminfo","modules","iomen",
"partitions","swap","cpuinfo"};
COPY_SENDF *c_Send=new class COPY_SENDF[8];
for(int i=0;i<8;i++)
{
c_Send[i].read(write_proc(files_proc[i]),info);
c_Send[i].s_Copy();
}
delete [] c_Send;
return 0;
}
YOU CAN PAY ME - https://paypal.me/LukaszW77?locale.x=pl_PL
Brak komentarzy:
Prześlij komentarz