-r is working
This commit is contained in:
14
src/client.c
14
src/client.c
@ -601,13 +601,13 @@ int cmd_W(char *filelist, char *Dir, int print) {
|
||||
opened = 1;
|
||||
}
|
||||
|
||||
if (opened && writeFile(token, Dir) == -1) {
|
||||
if (opened && (writeFile(token, Dir) == -1)) {
|
||||
ok = 0;
|
||||
}
|
||||
|
||||
if (opened && !ok) { // errore precedente -> elimino il file vuoto
|
||||
removeFile(token);
|
||||
} else if (opened && closeFile(token) == -1) { // chiudo il file
|
||||
} else if (opened && (closeFile(token) == -1)) { // chiudo il file
|
||||
ok = 0;
|
||||
}
|
||||
|
||||
@ -671,9 +671,11 @@ int cmd_r(char *filelist, char *dir, int print) {
|
||||
void *buf = NULL;
|
||||
size_t size = -1;
|
||||
|
||||
// printInfo(0, stdout);
|
||||
printInfo(0, stdout);
|
||||
// read the content of the file
|
||||
if (ok && readFile(token, &buf, &size) == -1) {
|
||||
fprintf(stdout, "\nreadFile\n");
|
||||
fflush(stdout);
|
||||
ok = 0;
|
||||
}
|
||||
if (print) {
|
||||
@ -689,6 +691,8 @@ int cmd_r(char *filelist, char *dir, int print) {
|
||||
|
||||
// close the file
|
||||
if (opened && closeFile(token) == -1) {
|
||||
fprintf(stdout, "\ncloseFile\n");
|
||||
fflush(stdout);
|
||||
ok = 0;
|
||||
}
|
||||
if (print) {
|
||||
@ -696,9 +700,7 @@ int cmd_r(char *filelist, char *dir, int print) {
|
||||
|
||||
if (ok) {
|
||||
printf("ok");
|
||||
}
|
||||
|
||||
else {
|
||||
} else {
|
||||
printf("errore");
|
||||
perror("-r");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user