-w, -W, -r all working
This commit is contained in:
@ -1259,7 +1259,6 @@ int reciveData(response_t *res, int expected) {
|
||||
readnres = readn(fd_skt, &res->numfiles, sizeof(int));
|
||||
if(readnres<=0) // readn sets errno
|
||||
return -1;
|
||||
|
||||
if(res->rf)
|
||||
free(res->rf);
|
||||
res->rf = calloc(res->numfiles, sizeof(recivedFile_t));
|
||||
@ -1267,6 +1266,7 @@ int reciveData(response_t *res, int expected) {
|
||||
perror("calloc");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// get files
|
||||
for(int i=0;i<res->numfiles;++i) {
|
||||
// read path
|
||||
@ -1350,10 +1350,11 @@ _nofile:
|
||||
// file purged
|
||||
res->meerrno = 0;
|
||||
// get number of files sent
|
||||
readnres = readn(fd_skt, &res->numfiles, sizeof(int));
|
||||
readnres = readn(fd_skt, &res->numfiles, sizeof(int64_t));
|
||||
if(readnres<=0) // readn sets errno
|
||||
return -1;
|
||||
|
||||
|
||||
if(res->rf)
|
||||
free(res->rf);
|
||||
res->rf = calloc(res->numfiles, sizeof(recivedFile_t));
|
||||
@ -1386,6 +1387,16 @@ _nofile:
|
||||
readnres = readn(fd_skt, &res->rf[i].filelen, sizeof(int64_t));
|
||||
if(readnres<=0) // readn sets errno
|
||||
return -1;
|
||||
|
||||
// file has lenght 0 -> allocate memory but dont read
|
||||
if(res->rf[i].filelen == 0) {
|
||||
res->rf[i].file = calloc(1, sizeof(char));
|
||||
if(!res->rf[i].file){
|
||||
perror("calloc");
|
||||
return -1;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
res->rf[i].file = calloc(res->rf[i].filelen, sizeof(char));
|
||||
if(!res->rf[i].file){
|
||||
perror("calloc");
|
||||
|
||||
Reference in New Issue
Block a user