Fixed bug with creating a new file, and then saving it

master
Aadhavan Srinivasan 2 years ago
parent f4f19c7c39
commit 230d26e411

@ -158,9 +158,7 @@ int is_file(char* path) {
}
void save_text_helper(Buffer* buffer,char* filename) {
if (is_file(filename) == 1) {
FILE* file = fopen(filename,"w");
int i = 0;
while (i < buffer->size) {
if ((buffer->start - buffer->text) == i) { /* If we have encountered
@ -171,12 +169,9 @@ void save_text_helper(Buffer* buffer,char* filename) {
if (i >= buffer->size) {
break;
}
fputc(*(buffer->text + i),file);
i++;
}
}
}
void init_curses() {
@ -207,16 +202,12 @@ int main(int argc, char** argv) {
num_of_chars++;
}
} else {
printf("File does not exist.\n");
return -10;
}
while (num_of_chars > 0) {
buffer_left(buffer);
num_of_chars--;
}
}
}
init_curses();
int ch;
@ -302,8 +293,6 @@ int main(int argc, char** argv) {
}
continue_while_loop:
}
endwin();
}

Loading…
Cancel
Save