Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
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
Иван Мажукин
mpd
Commits
701fff03
Commit
701fff03
authored
Jan 30, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
archive/bzip2: create file only after stream has been opened
Simplify error handling.
parent
8e0575ca
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
24 deletions
+19
-24
Bzip2ArchivePlugin.cxx
src/archive/Bzip2ArchivePlugin.cxx
+19
-24
No files found.
src/archive/Bzip2ArchivePlugin.cxx
View file @
701fff03
...
@@ -46,18 +46,28 @@ class Bzip2ArchiveFile : public ArchiveFile {
...
@@ -46,18 +46,28 @@ class Bzip2ArchiveFile : public ArchiveFile {
public
:
public
:
RefCount
ref
;
RefCount
ref
;
char
*
name
;
char
*
const
name
;
struct
input_stream
*
istream
;
struct
input_stream
*
const
istream
;
Bzip2ArchiveFile
(
const
char
*
path
,
input_stream
*
_is
)
:
ArchiveFile
(
bz2_archive_plugin
),
name
(
g_path_get_basename
(
path
)),
istream
(
_is
)
{
// remove .bz2 suffix
size_t
len
=
strlen
(
name
);
if
(
len
>
4
)
name
[
len
-
4
]
=
0
;
}
Bzip2ArchiveFile
()
:
ArchiveFile
(
bz2_archive_plugin
)
{}
~
Bzip2ArchiveFile
()
{
input_stream_close
(
istream
);
}
void
Unref
()
{
void
Unref
()
{
if
(
!
ref
.
Decrement
())
if
(
!
ref
.
Decrement
())
return
;
return
;
g_free
(
name
);
g_free
(
name
);
input_stream_close
(
istream
);
delete
this
;
delete
this
;
}
}
};
};
...
@@ -123,28 +133,13 @@ Bzip2InputStream::Close()
...
@@ -123,28 +133,13 @@ Bzip2InputStream::Close()
static
ArchiveFile
*
static
ArchiveFile
*
bz2_open
(
const
char
*
pathname
,
GError
**
error_r
)
bz2_open
(
const
char
*
pathname
,
GError
**
error_r
)
{
{
Bzip2ArchiveFile
*
context
=
new
Bzip2ArchiveFile
();
int
len
;
//open archive
static
Mutex
mutex
;
static
Mutex
mutex
;
static
Cond
cond
;
static
Cond
cond
;
context
->
istream
=
input_stream_open
(
pathname
,
mutex
,
cond
,
input_stream
*
is
=
input_stream_open
(
pathname
,
mutex
,
cond
,
error_r
);
error_r
);
if
(
is
==
nullptr
)
if
(
context
->
istream
==
NULL
)
{
return
nullptr
;
delete
context
;
return
NULL
;
}
context
->
name
=
g_path_get_basename
(
pathname
);
//remove suffix
len
=
strlen
(
context
->
name
);
if
(
len
>
4
)
{
context
->
name
[
len
-
4
]
=
0
;
//remove .bz2 suffix
}
return
context
;
return
new
Bzip2ArchiveFile
(
pathname
,
is
)
;
}
}
static
void
static
void
...
...
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