void running_for_first_time (void) { check_type_sizes (); if (config_filename) { return; // Do not create custom config file } tasprintf (&config_filename, "%s/%s/%s", get_home_directory (), CONFIG_DIRECTORY, CONFIG_FILE); config_filename = make_full_path (config_filename); int config_file_fd; char *config_directory = get_config_directory (); //char *downloads_directory = get_downloads_directory (); if (!mkdir (config_directory, CONFIG_DIRECTORY_MODE)) { if (!disable_output) { printf ("[%s] created\n", config_directory); } } tfree_str (config_directory); config_directory = NULL; // see if config file is there if (access (config_filename, R_OK) != 0) { // config file missing, so touch it config_file_fd = open (config_filename, O_CREAT | O_RDWR, 0600); if (config_file_fd == -1) { perror ("open[config_file]"); exit (EXIT_FAILURE); } if (write (config_file_fd, DEFAULT_CONFIG_CONTENTS, strlen (DEFAULT_CONFIG_CONTENTS)) <= 0) { perror ("write[config_file]"); exit (EXIT_FAILURE); } close (config_file_fd); /*int auth_file_fd = open (get_auth_key_filename (), O_CREAT | O_RDWR, 0600); int x = -1; assert (write (auth_file_fd, &x, 4) == 4); close (auth_file_fd); printf ("[%s] created\n", config_filename);*/ /* create downloads directory */ /*if (mkdir (downloads_directory, 0755) !=0) { perror ("creating download directory"); exit (EXIT_FAILURE); }*/ } }
void running_for_first_time (void) { check_type_sizes (); if (!str_empty (config_filename)) { return; // Do not create custom config file } if (str_empty (config_directory)) { config_directory = get_config_directory (); } tasprintf (&config_filename, "%s/%s", config_directory, CONFIG_FILE); config_filename = make_full_path (config_filename); if (!disable_output) { printf ("I: config dir=[%s]\n", config_directory); } // printf ("I: config file=[%s]\n", config_filename); int config_file_fd; //char *config_directory = get_config_directory (); //char *downloads_directory = get_downloads_directory (); if (!mkdir (config_directory, CONFIG_DIRECTORY_MODE)) { if (!disable_output) { printf ("[%s] created\n", config_directory); } } tfree_str (config_directory); config_directory = NULL; // see if config file is there if (access (config_filename, R_OK) != 0) { // config file missing, so touch it config_file_fd = open (config_filename, O_CREAT | O_RDWR, 0600); if (config_file_fd == -1) { perror ("open[config_file]"); printf ("I: config_file=[%s]\n", config_filename); exit (EXIT_FAILURE); } if (write (config_file_fd, DEFAULT_CONFIG_CONTENTS, strlen (DEFAULT_CONFIG_CONTENTS)) <= 0) { perror ("write[config_file]"); exit (EXIT_FAILURE); } close (config_file_fd); } }