Final Fixes for bad file name
This commit is contained in:
parent
4c16753fb9
commit
3daf9ab37d
3 changed files with 11 additions and 4 deletions
|
@ -6,7 +6,8 @@ struct node* parse_csv(char* name) {
|
|||
file = fopen(name, "r");
|
||||
if(!file) {
|
||||
perror("Error");
|
||||
exit(66);
|
||||
printf("\n");
|
||||
return NULL;
|
||||
|
||||
}
|
||||
// Buffer File For chars
|
||||
|
@ -35,7 +36,7 @@ struct node* parse_csv(char* name) {
|
|||
free(buffer);
|
||||
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;
|
||||
|
||||
|
|
|
@ -92,11 +92,14 @@ void choose_movie(char* dir_str) {
|
|||
//printf("\nDirectory: %s\n", dir_str);
|
||||
struct node* head = parse_csv(dir_str);
|
||||
|
||||
if(!head)
|
||||
return;
|
||||
|
||||
// Generate the String for movies
|
||||
char* dir = malloc(sizeof(char)*100);
|
||||
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);
|
||||
|
||||
free(dir_str);
|
||||
|
@ -132,6 +135,9 @@ void index_nodes(int* val, void* head) {
|
|||
|
||||
void print_csv(struct node* head, char* dir) {
|
||||
|
||||
if(!head)
|
||||
return;
|
||||
|
||||
int result = mkdir(dir, 0750);
|
||||
|
||||
chdir(dir);
|
||||
|
|
|
@ -34,5 +34,5 @@ make run
|
|||
To specify a CSV file, you can type:
|
||||
|
||||
```
|
||||
./movies_by_year $(CSV_File_to_read.csv)
|
||||
./movies_by_year
|
||||
```
|
||||
|
|
Loading…
Reference in a new issue