aboutsummaryrefslogtreecommitdiffstats
path: root/src/encoderB64.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/encoderB64.cpp28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/encoderB64.cpp b/src/encoderB64.cpp
index bb78ac6a..9e290b57 100644
--- a/src/encoderB64.cpp
+++ b/src/encoderB64.cpp
@@ -70,7 +70,8 @@ const unsigned char encoderB64::sm_decodeMap[256] =
-const utility::stream::size_type encoderB64::encode(utility::inputStream& in, utility::outputStream& out)
+const utility::stream::size_type encoderB64::encode(utility::inputStream& in,
+ utility::outputStream& out, utility::progressionListener* progress)
{
in.reset(); // may not work...
@@ -88,9 +89,13 @@ const utility::stream::size_type encoderB64::encode(utility::inputStream& in, ut
unsigned char output[4];
utility::stream::size_type total = 0;
+ utility::stream::size_type inTotal = 0;
int curCol = 0;
+ if (progress)
+ progress->start(0);
+
while (bufferPos < bufferLength || !in.eof())
{
if (bufferPos >= bufferLength)
@@ -156,6 +161,7 @@ const utility::stream::size_type encoderB64::encode(utility::inputStream& in, ut
// Write encoded data to output stream
B64_WRITE(out, output, 4);
+ inTotal += count;
total += 4;
curCol += 4;
@@ -164,13 +170,20 @@ const utility::stream::size_type encoderB64::encode(utility::inputStream& in, ut
out.write("\r\n", 2);
curCol = 0;
}
+
+ if (progress)
+ progress->progress(inTotal, inTotal);
}
+ if (progress)
+ progress->stop(inTotal);
+
return (total);
}
-const utility::stream::size_type encoderB64::decode(utility::inputStream& in, utility::outputStream& out)
+const utility::stream::size_type encoderB64::decode(utility::inputStream& in,
+ utility::outputStream& out, utility::progressionListener* progress)
{
in.reset(); // may not work...
@@ -180,10 +193,14 @@ const utility::stream::size_type encoderB64::decode(utility::inputStream& in, ut
int bufferPos = 0;
utility::stream::size_type total = 0;
+ utility::stream::size_type inTotal = 0;
unsigned char bytes[4];
unsigned char output[3];
+ if (progress)
+ progress->start(0);
+
while (bufferPos < bufferLength || !in.eof())
{
bytes[0] = '=';
@@ -265,8 +282,15 @@ const utility::stream::size_type encoderB64::decode(utility::inputStream& in, ut
B64_WRITE(out, output, 3);
total += 3;
+ inTotal += count;
+
+ if (progress)
+ progress->progress(inTotal, inTotal);
}
+ if (progress)
+ progress->stop(inTotal);
+
return (total);
}