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

parent 85f099ce
...@@ -69,20 +69,24 @@ main(int argc, char** argv) ...@@ -69,20 +69,24 @@ main(int argc, char** argv)
FILE *url_file = NULL; FILE *url_file = NULL;
FILE *filepaths_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){ switch(download_type){
case URL_ONLY: case URL_ONLY:
download_file(url, filepath, curl); download_file(url, filepath, curl);
break; break;
//TODO:refactor (merge if possible) 2 cases below
case URL_FILE_ONLY: case URL_FILE_ONLY:
url_file = fopen(url_file_path, "r"); url_file = fopen(url_file_path, "r");
if(!url_file) if(!url_file)
die("Could not open given url file!"); die("Could not open given url file!");
char *curr_url; while(getline(&curr_url, &url_len, url_file) != -1){
size_t len = 0;
while(getline(&curr_url, &len, url_file) != -1){
if (curr_url[strlen(curr_url) - 1] == '\n') if (curr_url[strlen(curr_url) - 1] == '\n')
curr_url[strlen(curr_url) - 1] = '\0'; curr_url[strlen(curr_url) - 1] = '\0';
...@@ -94,7 +98,30 @@ main(int argc, char** argv) ...@@ -94,7 +98,30 @@ main(int argc, char** argv)
fclose(url_file); fclose(url_file);
break; break;
case URL_FILE_AND_FILEPATHS_FILE: 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; break;
} }
curl_easy_cleanup(curl); 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