#include <string.h>
#include <algorithm> // std::random_shuffle
#include <vector> // std::vector
+#include <unistd.h>
+#include <thread>
+
+
extern "C" {
#include "jerasure.h"
}
using namespace std;
-string cloud[5]={"dropboxida1","googleida1","megaida1","onedriveida1","pcloudida1"};
+string cloud[5]={"dropboxida1","googleida1","onedriveida2","onedriveida1","pcloudida1"};
void display(mylong *mat, int r, int c) {
mylong* readFullFile(int n, int t, mylong& sizeFile, mylong & padded_size) {
- ifstream stream("lena.png", ios::in | ios::binary | ios::ate);
+// ifstream stream("lena.png", ios::in | ios::binary | ios::ate);
// ifstream stream("lena_small.png", ios::in | ios::binary | ios::ate);
-// ifstream stream("/home/couturie/Downloads/CARCARIASS.zip", ios::in | ios::binary | ios::ate);
+ ifstream stream("/home/couturie/Downloads/CARCARIASS.zip", ios::in | ios::binary | ios::ate);
sizeFile=stream.tellg();
std::cout << sizeFile << std::endl;
mylong *identity;
- int size=5000000;
+// int size=5000000;
int t=3;
int n=5;
// display(matC,t,t);
-
+ thread th[n];
//Save trunks
for(int i=0;i<n;i++) {
stringstream ss;
- ss <<"lena_"<<i<<".png";
+ ss <<"file_"<<i<<".dat";
string str = ss.str();
saveFile((uint8_t*)&matC[i*len], str.c_str(),len*sizeof(mylong));
- sendChunk( str,i);
+// sendChunk( str,i);
+ th[i] = thread(sendChunk,str, i);
}
+ for(int i=0;i<n;i++) {
+ th[i].join();
+ }
+/* cout<<"sleep begin"<<endl;
+ sleep(2);
+ cout<<"sleep end"<<endl;
+*/
+
mylong *matCs = malloc(sizeof(mylong)*t*len);
mylong *matGs = malloc(sizeof(mylong)*t*t);
std::cout << "random chunk" << std::endl;
int ind=0;
+
+
+
for(int ii=0;ii<t;ii++) {
-// for(int i=n-1;i>=t;i--) {
-// for(int i=0;i<n;i+=2) {
auto i=myvector[ii];
std::cout << myvector[i] << " ";
stringstream ss;
- ss <<"lena_"<<i<<".png";
+ ss <<"file_"<<i<<".dat";
string str = ss.str();
- retrieveChunk(str,i);
+// retrieveChunk(str,i);
+ th[ii] = thread(retrieveChunk,str, i);
+ }
+
+
+ ind=0;
+
+ for(int ii=0;ii<t;ii++) {
+
+ auto i=myvector[ii];
+ std::cout << myvector[i] << " ";
+
+
+ stringstream ss;
+ ss <<"file_"<<i<<".dat";
+ string str = ss.str();
+ th[ii].join();
readFile((uint8_t*)&matCs[ind*len], str.c_str(),len*sizeof(mylong));
// display(&matCs[ind*len],1,1);
//first elements that contains the size is removed
uint8_t *reconstucted_data=reinterpret_cast<uint8_t*>(&matS2[1]);
- saveFile(reconstucted_data, "lena2.png",new_size);
+ saveFile(reconstucted_data, "file.dat",new_size);
return 0;
}