Why was I dumb? #1

Merged
stitchy merged 3 commits from test into master 2023-11-15 03:43:16 -08:00
3 changed files with 11 additions and 4 deletions
Showing only changes of commit 3daf9ab37d - Show all commits

View file

@ -6,7 +6,8 @@ struct node* parse_csv(char* name) {
file = fopen(name, "r"); file = fopen(name, "r");
if(!file) { if(!file) {
perror("Error"); perror("Error");
exit(66); printf("\n");
return NULL;
} }
// Buffer File For chars // Buffer File For chars
@ -35,7 +36,7 @@ struct node* parse_csv(char* name) {
free(buffer); free(buffer);
fclose(file); fclose(file);
printf("Processed file %s and processed data for %d movies.\n\n", name, count_nodes(head)); printf("Processed file %s and processed data for %d movies.\n", name, count_nodes(head));
return head; return head;

View file

@ -92,11 +92,14 @@ void choose_movie(char* dir_str) {
//printf("\nDirectory: %s\n", dir_str); //printf("\nDirectory: %s\n", dir_str);
struct node* head = parse_csv(dir_str); struct node* head = parse_csv(dir_str);
if(!head)
return;
// Generate the String for movies // Generate the String for movies
char* dir = malloc(sizeof(char)*100); char* dir = malloc(sizeof(char)*100);
sprintf(dir, "temp.movies.%d", rand() % 100000); sprintf(dir, "temp.movies.%d", rand() % 100000);
printf("Created directory with the name %s\n", dir); printf("Created directory with the name %s\n\n", dir);
print_csv(head, dir); print_csv(head, dir);
free(dir_str); free(dir_str);
@ -132,6 +135,9 @@ void index_nodes(int* val, void* head) {
void print_csv(struct node* head, char* dir) { void print_csv(struct node* head, char* dir) {
if(!head)
return;
int result = mkdir(dir, 0750); int result = mkdir(dir, 0750);
chdir(dir); chdir(dir);

View file

@ -34,5 +34,5 @@ make run
To specify a CSV file, you can type: To specify a CSV file, you can type:
``` ```
./movies_by_year $(CSV_File_to_read.csv) ./movies_by_year
``` ```