Started working on file opening support

master
Aadhavan Srinivasan 2 years ago
parent 68305de7f6
commit 25c1f6a2c1

@ -4,6 +4,7 @@
#include <signal.h> #include <signal.h>
#include <string.h> #include <string.h>
#include <stdbool.h> #include <stdbool.h>
#include <unistd.h>
typedef struct Buffer_struct Buffer; typedef struct Buffer_struct Buffer;
struct Buffer_struct { struct Buffer_struct {
@ -93,10 +94,25 @@ void sigint_handler(int dummy) {
exit(130); exit(130);
} }
int main() { int main(int argc, char** argv) {
signal(SIGINT,sigint_handler); signal(SIGINT,sigint_handler);
Buffer* buffer = new_buffer(10); Buffer* buffer = new_buffer(10);
if (argc == 2) {
if (access(argv[1],F_OK) == 0) { /* If the file exists */
FILE* file = fopen(argv[1],"r");
char c;
while (c = fgetc(file) != EOF) {
buffer_insert(c,buffer);
}
} else {
printf("File does not exist.\n");
return -10;
}
}
init_curses(); init_curses();
int ch; int ch;

Loading…
Cancel
Save