Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jan Paul Batrina
Ark
Commits
4c613799
Commit
4c613799
authored
Jul 23, 2008
by
Harald Hvaal
Browse files
Added progress feedback to libarchivehandler
svn path=/trunk/KDE/kdeutils/ark/; revision=836960
parent
1aa6f47f
Changes
2
Hide whitespace changes
Inline
Side-by-side
plugins/libarchive/libarchivehandler.cpp
View file @
4c613799
...
...
@@ -41,7 +41,8 @@
#include <QDateTime>
LibArchiveInterface
::
LibArchiveInterface
(
const
QString
&
filename
,
QObject
*
parent
)
:
ReadOnlyArchiveInterface
(
filename
,
parent
)
:
ReadOnlyArchiveInterface
(
filename
,
parent
),
cachedArchiveEntryCount
(
-
1
)
{
}
...
...
@@ -72,6 +73,8 @@ bool LibArchiveInterface::list()
error
(
QString
(
"Could not open the file '%1', libarchive cannot handle it."
).
arg
(
filename
()
),
QString
()
);
return
false
;
}
cachedArchiveEntryCount
=
0
;
while
(
(
result
=
archive_read_next_header
(
arch
,
&
aentry
)
)
==
ARCHIVE_OK
)
{
...
...
@@ -89,6 +92,7 @@ bool LibArchiveInterface::list()
e
[
Timestamp
]
=
QDateTime
::
fromTime_t
(
archive_entry_mtime
(
aentry
)
);
entry
(
e
);
archive_read_data_skip
(
arch
);
cachedArchiveEntryCount
++
;
}
if
(
result
!=
ARCHIVE_EOF
)
...
...
@@ -137,17 +141,38 @@ bool LibArchiveInterface::copyFiles( const QList<QVariant> & files, const QStrin
return
false
;
}
int
entryNr
=
0
,
totalCount
=
-
1
;
if
(
extractAll
)
{
if
(
cachedArchiveEntryCount
==
-
1
)
{
progress
(
0
);
//TODO: once information progress has been implemented, send
//feedback here that the archive is being read
list
();
}
totalCount
=
cachedArchiveEntryCount
;
}
else
totalCount
=
files
.
size
();
while
(
archive_read_next_header
(
arch
,
&
entry
)
==
ARCHIVE_OK
)
{
QString
entryName
=
QFile
::
decodeName
(
archive_entry_pathname
(
entry
)
);
if
(
entries
.
contains
(
entryName
)
||
extractAll
)
{
if
(
!
preservePaths
)
archive_entry_set_pathname
(
entry
,
QFile
::
encodeName
(
QFileInfo
(
entryName
).
fileName
()
).
constData
()
);
if
(
archive_write_header
(
writer
,
entry
)
==
ARCHIVE_OK
)
copyData
(
arch
,
writer
);
if
(
cachedArchiveEntryCount
!=
-
1
)
{
++
entryNr
;
progress
(
float
(
entryNr
)
/
totalCount
);
}
archive_entry_clear
(
entry
);
entries
.
removeAll
(
entryName
);
}
...
...
plugins/libarchive/libarchivehandler.h
View file @
4c613799
...
...
@@ -43,6 +43,7 @@ class LibArchiveInterface: public ReadOnlyArchiveInterface
private:
int
extractionFlags
()
const
;
void
copyData
(
struct
archive
*
source
,
struct
archive
*
dest
);
int
cachedArchiveEntryCount
;
};
#endif // LIBARCHIVEHANDLER_H
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