Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
htslib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Thierry Schuepbach
htslib
Commits
ef895567
Commit
ef895567
authored
Apr 4, 2018
by
jrayner
Browse files
Options
Downloads
Patches
Plain Diff
add integrity check option
parent
5b60dd3f
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
bgzip.c
+13
-8
13 additions, 8 deletions
bgzip.c
with
13 additions
and
8 deletions
bgzip.c
+
13
−
8
View file @
ef895567
...
...
@@ -85,13 +85,14 @@ static int bgzip_main_usage(void)
fprintf
(
stderr
,
" -g, --rebgzip use an index file to bgzip a file
\n
"
);
fprintf
(
stderr
,
" -s, --size INT decompress INT bytes (uncompressed size)
\n
"
);
fprintf
(
stderr
,
" -@, --threads INT number of compression threads to use [1]
\n
"
);
fprintf
(
stderr
,
" -t, --test test integrity of compressed file"
);
fprintf
(
stderr
,
"
\n
"
);
return
1
;
}
int
main
(
int
argc
,
char
**
argv
)
{
int
c
,
compress
,
compress_level
=
-
1
,
pstdout
,
is_forced
,
index
=
0
,
rebgzip
=
0
,
reindex
=
0
;
int
c
,
compress
,
compress_level
=
-
1
,
pstdout
,
is_forced
,
test
,
index
=
0
,
rebgzip
=
0
,
reindex
=
0
;
BGZF
*
fp
;
void
*
buffer
;
long
start
,
end
,
size
;
...
...
@@ -112,12 +113,13 @@ int main(int argc, char **argv)
{
"rebgzip"
,
no_argument
,
NULL
,
'g'
},
{
"size"
,
required_argument
,
NULL
,
's'
},
{
"threads"
,
required_argument
,
NULL
,
'@'
},
{
"test"
,
no_argument
,
NULL
,
't'
},
{
"version"
,
no_argument
,
NULL
,
1
},
{
NULL
,
0
,
NULL
,
0
}
};
compress
=
1
;
pstdout
=
0
;
start
=
0
;
size
=
-
1
;
end
=
-
1
;
is_forced
=
0
;
while
((
c
=
getopt_long
(
argc
,
argv
,
"cdh?fb:@:s:iI:l:gr"
,
loptions
,
NULL
))
>=
0
){
compress
=
1
;
pstdout
=
0
;
start
=
0
;
size
=
-
1
;
end
=
-
1
;
is_forced
=
0
;
test
=
0
;
while
((
c
=
getopt_long
(
argc
,
argv
,
"cdh?fb:@:s:iI:l:gr
t
"
,
loptions
,
NULL
))
>=
0
){
switch
(
c
){
case
'd'
:
compress
=
0
;
break
;
case
'c'
:
pstdout
=
1
;
break
;
...
...
@@ -130,6 +132,7 @@ int main(int argc, char **argv)
case
'g'
:
rebgzip
=
1
;
break
;
case
'r'
:
reindex
=
1
;
compress
=
0
;
break
;
case
'@'
:
threads
=
atoi
(
optarg
);
break
;
case
't'
:
test
=
1
;
compress
=
0
;
reindex
=
0
;
break
;
case
1
:
printf
(
"bgzip (htslib) %s
\n
"
...
...
@@ -303,7 +306,7 @@ int main(int argc, char **argv)
return
1
;
}
if
(
pstdout
)
{
if
(
pstdout
||
test
)
{
f_dst
=
fileno
(
stdout
);
}
else
{
...
...
@@ -350,17 +353,19 @@ int main(int argc, char **argv)
if
(
c
==
0
)
break
;
if
(
c
<
0
)
error
(
"Could not read %d bytes: Error %d
\n
"
,
(
end
-
start
>
WINDOW_SIZE
)
?
WINDOW_SIZE
:
(
end
-
start
),
fp
->
errcode
);
start
+=
c
;
if
(
!
test
)
{
if
(
write
(
f_dst
,
buffer
,
c
)
!=
c
)
{
#ifdef _WIN32
if
(
GetLastError
()
!=
ERROR_NO_DATA
)
#endif
error
(
"Could not write %d bytes
\n
"
,
c
);
}
}
if
(
end
>=
0
&&
start
>=
end
)
break
;
}
free
(
buffer
);
if
(
bgzf_close
(
fp
)
<
0
)
error
(
"Close failed: Error %d
\n
"
,
fp
->
errcode
);
if
(
!
pstdout
)
unlink
(
argv
[
optind
]);
if
(
!
pstdout
&&
!
test
)
unlink
(
argv
[
optind
]);
return
0
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment