Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
C programming 2nd term
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ильин Владимир Александрович
C programming 2nd term
Commits
65a62362
Commit
65a62362
authored
May 01, 2024
by
Ильин Владимир Александрович
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
-uf теперь работает!
parent
85f099ce
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
5 deletions
+36
-5
main.c
avtomat/main.c
+32
-5
test_filepaths.txt
avtomat/test_filepaths.txt
+4
-0
No files found.
avtomat/main.c
View file @
65a62362
...
...
@@ -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
);
...
...
avtomat/test_filepaths.txt
0 → 100644
View file @
65a62362
9base.tar.gz
dwm.tar.gz
st.tar.gz
dmenu.tar.gz
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment