-uf теперь работает!

parent 85f099ce
......@@ -69,20 +69,24 @@ main(int argc, char** argv)
FILE *url_file = NULL;
FILE *filepaths_file = NULL;
char *curr_url;
char *curr_filepath;
size_t url_len = 0;
size_t filepath_len = 0;
switch(download_type){
case URL_ONLY:
download_file(url, filepath, curl);
break;
//TODO:refactor (merge if possible) 2 cases below
case URL_FILE_ONLY:
url_file = fopen(url_file_path, "r");
if(!url_file)
die("Could not open given url file!");
char *curr_url;
size_t len = 0;
while(getline(&curr_url, &len, url_file) != -1){
while(getline(&curr_url, &url_len, url_file) != -1){
if (curr_url[strlen(curr_url) - 1] == '\n')
curr_url[strlen(curr_url) - 1] = '\0';
......@@ -94,7 +98,30 @@ main(int argc, char** argv)
fclose(url_file);
break;
case URL_FILE_AND_FILEPATHS_FILE:
puts("-uf and -ff case");
url_file = fopen(url_file_path, "r");
filepaths_file = fopen(filepaths_file_path, "r");
if(!url_file)
die("Could not open given url file!");
if(!filepaths_file)
die("Could not open given filepaths file!");
while(getline(&curr_url, &filepath_len, url_file) != -1){
if(getline(&curr_filepath, &url_len, filepaths_file) == -1)
curr_filepath = get_default_filepath(curr_url);
if (curr_filepath[strlen(curr_filepath) - 1] == '\n')
curr_filepath[strlen(curr_filepath) - 1] = '\0';
if (curr_url[strlen(curr_url) - 1] == '\n')
curr_url[strlen(curr_url) - 1] = '\0';
download_file(curr_url, curr_filepath, curl);
}
free(curr_url);
fclose(url_file);
break;
}
curl_easy_cleanup(curl);
......
9base.tar.gz
dwm.tar.gz
st.tar.gz
dmenu.tar.gz
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment