* Changed the UnzipEngine to be a BCommandPipe::LineReader itself, this
simplified the code somewhat (maintaining of state). * UnzipEngine does a more complete parsing of the .zip contents and maintains a hashmap of item names to byte size entries. During unzipping later on, this allows to know how many bytes were unzipped for the given item. * Test whether folders from the .zip already exists, and exclude them from the item count, since unzip will not report creating folders that already existed. * Added the unzipping of packages in the _package_ folder to WorkerThread, but it is currently commented out to keep Installer in a working state. It would work, but the problem is that the progress bar would reset itself at the moment (for every package). * Started a ProgressReporter class that will later be used by all CopyEngine and UnzipEngine instances. This is work in progress and not yet part of the build. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32959 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright 2009, Stephan Aßmus <[email protected]>
|
||||
* All rights reserved. Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
#include "ProgressReporter.h"
|
||||
|
||||
#include <new>
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
using std::nothrow;
|
||||
|
||||
|
||||
ProgressReporter::ProgressReporter(const BMessenger& messenger,
|
||||
BMessage* message)
|
||||
:
|
||||
fBytesRead(0),
|
||||
fItemsCopied(0),
|
||||
fTimeRead(0),
|
||||
|
||||
fBytesWritten(0),
|
||||
fTimeWritten(0),
|
||||
|
||||
fBytesToCopy(0),
|
||||
fItemsToCopy(0),
|
||||
|
||||
fMessenger(messenger),
|
||||
fMessage(message)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
ProgressReporter::~ProgressReporter()
|
||||
{
|
||||
delete fMessage;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ProgressReporter::Reset()
|
||||
{
|
||||
fBytesRead = 0;
|
||||
fItemsCopied = 0;
|
||||
fTimeRead = 0;
|
||||
|
||||
fBytesWritten = 0;
|
||||
fTimeWritten = 0;
|
||||
|
||||
fBytesToCopy = 0;
|
||||
fItemsToCopy = 0;
|
||||
|
||||
if (fMessage) {
|
||||
BMessage message(*fMessage);
|
||||
message.AddString("status", "Collecting copy information.");
|
||||
fMessenger.SendMessage(&message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ProgressReporter::AddItems(uint64 count, off_t bytes)
|
||||
{
|
||||
// TODO ...
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ProgressReporter::StartTimer()
|
||||
{
|
||||
// TODO ...
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ProgressReporter::ItemsCopied(uint64 items, off_t bytes, const char* itemName,
|
||||
const char* targetFolder)
|
||||
{
|
||||
// TODO ...
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ProgressReporter::_UpdateProgress(const char* itemName,
|
||||
const char* targetFolder)
|
||||
{
|
||||
if (fMessage != NULL) {
|
||||
BMessage message(*fMessage);
|
||||
float progress = 100.0 * fBytesRead / fBytesToCopy;
|
||||
message.AddFloat("progress", progress);
|
||||
message.AddInt32("current", fItemsCopied);
|
||||
message.AddInt32("maximum", fItemsToCopy);
|
||||
message.AddString("item", itemName);
|
||||
message.AddString("folder", targetFolder);
|
||||
fMessenger.SendMessage(&message);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user