fixed -r and -d
This commit is contained in:
@ -1,12 +1,12 @@
|
|||||||
[threadpool]
|
[threadpool]
|
||||||
|
|
||||||
quantity = 10
|
quantity = 1
|
||||||
pending = 20
|
pending = 10
|
||||||
|
|
||||||
[files]
|
[files]
|
||||||
|
|
||||||
MaxFiles = 2
|
MaxFiles = 10000
|
||||||
MaxSize = 10000000
|
MaxSize = 128000
|
||||||
|
|
||||||
[log]
|
[log]
|
||||||
|
|
||||||
|
|||||||
@ -397,7 +397,7 @@ int readFile(const char* pathname, void** buf, size_t* size) {
|
|||||||
fflush(openedFiles->out);
|
fflush(openedFiles->out);
|
||||||
}
|
}
|
||||||
if(storeFilesInDirectory(openedFiles->rDir, 1, res->rf) == -1) {
|
if(storeFilesInDirectory(openedFiles->rDir, 1, res->rf) == -1) {
|
||||||
perror("storeFilesindirectory");
|
perror("storeFilesInDirectory");
|
||||||
freeResponse(res);
|
freeResponse(res);
|
||||||
free(res);
|
free(res);
|
||||||
free(cmd);
|
free(cmd);
|
||||||
@ -1442,7 +1442,7 @@ _nofile:
|
|||||||
}
|
}
|
||||||
|
|
||||||
int storeFilesInDirectory(const char *dirname, int n, recivedFile_t *rf) {
|
int storeFilesInDirectory(const char *dirname, int n, recivedFile_t *rf) {
|
||||||
if(!dirname || strcmp(dirname, "") || !rf || n<0) {
|
if(!dirname || strcmp(dirname, "")==0 || !rf || n<0) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,8 +37,8 @@ fileT* createFileT(char *f, int O_LOCK, int client, int open){
|
|||||||
strncpy(file->filepath, f, strnlen(f, MAXNAMELEN));
|
strncpy(file->filepath, f, strnlen(f, MAXNAMELEN));
|
||||||
|
|
||||||
// in seguito semplicemente facciamo realloc
|
// in seguito semplicemente facciamo realloc
|
||||||
if ((file->data = malloc(1)) == NULL) {
|
if ((file->data = calloc(1, sizeof(char))) == NULL) {
|
||||||
perror("Malloc content");
|
perror("Calloc content");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return file;
|
return file;
|
||||||
@ -51,7 +51,9 @@ int writeFileT(fileT *f, void *data, size_t size) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
size = (size == 0)?1:size;
|
if(size == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if ((f->data = realloc(f->data, f->valid + size)) == NULL) {
|
if ((f->data = realloc(f->data, f->valid + size)) == NULL) {
|
||||||
perror("Realloc content");
|
perror("Realloc content");
|
||||||
|
|||||||
Reference in New Issue
Block a user