[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/work/kde4/playground/libs/archivereader/src
From: Jos van den Oever <jos () vandenoever ! info>
Date: 2006-04-30 21:39:07
Message-ID: 1146433147.556390.5230.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 535982 by vandenoever:
Changed interface of StreamBase to return the new position in reset()
M +14 -13 streamindexer/digestthroughanalyzer.cpp
M +2 -2 streamindexer/streamendanalyzer.cpp
M +2 -3 streamindexer/streamindexer.cpp
M +4 -4 streams/bufferedstream.h
M +7 -4 streams/filereader.cpp
M +1 -1 streams/filereader.h
M +1 -1 streams/streambase.h
M +3 -3 streams/stringreader.h
M +9 -4 streams/subinputstream.cpp
M +1 -1 streams/subinputstream.h
--- branches/work/kde4/playground/libs/archivereader/src/streamindexer/digestthroughanalyzer.cpp \
#535981:535982 @@ -5,7 +5,6 @@
class DigestInputStream : public InputStream {
private:
- int32_t sinceMark;
int32_t ignoreBytes;
SHA_CTX sha1;
unsigned char digest[SHA_DIGEST_LENGTH];
@@ -14,14 +13,13 @@
DigestInputStream(InputStream *input);
int32_t read(const char*& start, int32_t min, int32_t max);
int64_t skip(int64_t ntoskip);
- StreamStatus mark(int32_t readlimit);
- StreamStatus reset();
+ int64_t mark(int32_t readlimit);
+ int64_t reset();
void printDigest();
};
DigestInputStream::DigestInputStream(InputStream *input) {
this->input = input;
status = Ok;
- sinceMark = 0;
ignoreBytes = 0;
SHA1_Init(&sha1);
}
@@ -37,7 +35,6 @@
status = Eof;
return Eof;
}
- sinceMark += nread;
if (ignoreBytes < nread) {
SHA1_Update(&sha1, start+ignoreBytes, nread-ignoreBytes);
ignoreBytes = 0;
@@ -52,20 +49,24 @@
// read() which is required for updating the hash
return input->skip(ntoskip);
}
-StreamStatus
+int64_t
DigestInputStream::mark(int32_t readlimit) {
if (status) return status;
- sinceMark = 0;
return input->mark(readlimit);
}
-StreamStatus
+int64_t
DigestInputStream::reset() {
- StreamStatus s = input->reset();
- if (s == Ok) {
- ignoreBytes += sinceMark;
- sinceMark = 0;
+ int64_t newpos = input->reset();
+ if (newpos < 0) {
+ status = Error;
+ error = input->getError();
+ } else {
+ if (newpos < position) {
+ ignoreBytes += position - newpos;
+ }
}
- return input->reset();
+ position = newpos;
+ return newpos;
}
void
DigestInputStream::printDigest() {
--- branches/work/kde4/playground/libs/archivereader/src/streamindexer/streamendanalyzer.cpp \
#535981:535982 @@ -7,8 +7,8 @@
int32_t testsize = 1;
const char *dummyptr;
int32_t nread;
- StreamStatus r = in->mark(testsize);
- if (r != Ok) {
+ int64_t r = in->mark(testsize);
+ if (r < 0) {
return -1;
}
nread = in->read(dummyptr, testsize, testsize);
--- branches/work/kde4/playground/libs/archivereader/src/streamindexer/streamindexer.cpp \
#535981:535982 @@ -78,14 +78,13 @@
input->mark(headersize); // set to size required to determine file type
const char* header;
headersize = input->read(header, headersize, headersize);
- StreamStatus r;
std::vector<StreamEndAnalyzer*>::iterator es = eIter->begin();
while (!finished && es != eIter->end()) {
if ((*es)->checkHeader(header, headersize)) {
char ar = (*es)->analyze(path, input, depth+1, this);
if (ar) {
- r = input->reset();
- if (r != Ok) { // could not reset
+ int64_t pos = input->reset();
+ if (pos != 0) { // could not reset
printf("could not reset\n");
return -2;
}
--- branches/work/kde4/playground/libs/archivereader/src/streams/bufferedstream.h \
#535981:535982 @@ -30,7 +30,7 @@
BufferedInputStream<T>();
int32_t read(const T*& start, int32_t min, int32_t max);
int64_t mark(int32_t readlimit);
- StreamStatus reset();
+ int64_t reset();
virtual int64_t skip(int64_t ntoskip);
};
@@ -89,15 +89,15 @@
return StreamBase<T>::position;
}
template <class T>
-StreamStatus
+int64_t
BufferedInputStream<T>::reset() {
if (buffer.markPos) {
BufferedInputStream<T>::position -= buffer.readPos - buffer.markPos;
buffer.reset();
- return Ok;
+ return BufferedInputStream<T>::position;
} else {
StreamBase<T>::error = "No valid mark for reset.";
- return Error;
+ return -1;
}
}
template <class T>
--- branches/work/kde4/playground/libs/archivereader/src/streams/filereader.cpp \
#535981:535982 @@ -30,10 +30,13 @@
int64_t mp = reader->mark(readlimit);
return mp;
}
-StreamStatus
+int64_t
FileReader::reset() {
- status = reader->reset();
- if (status != Ok) error = reader->getError();
- return status;
+ position = reader->reset();
+ if (position < 0) {
+ status = Error;
+ error = reader->getError();
+ }
+ return position;
}
--- branches/work/kde4/playground/libs/archivereader/src/streams/filereader.h \
#535981:535982 @@ -17,7 +17,7 @@
~FileReader();
int32_t read(const wchar_t*& start, int32_t min, int32_t max);
int64_t mark(int32_t readlimit);
- StreamStatus reset();
+ int64_t reset();
};
} // end namespace jstreams
--- branches/work/kde4/playground/libs/archivereader/src/streams/streambase.h \
#535981:535982 @@ -116,7 +116,7 @@
* would have been the next input data as of the time of the call to
* reset.
**/
- virtual StreamStatus reset() = 0;
+ virtual int64_t reset() = 0;
};
template <class T>
--- branches/work/kde4/playground/libs/archivereader/src/streams/stringreader.h \
#535981:535982 @@ -19,7 +19,7 @@
int32_t read(const T*& start, int32_t min, int32_t max);
int64_t skip(int64_t ntoskip);
int64_t mark(int32_t readlimit);
- StreamStatus reset();
+ int64_t reset();
};
template <class T>
@@ -79,7 +79,7 @@
return markpt;
}
template <class T>
-StreamStatus
+int64_t
StringReader<T>::reset() {
StreamBase<T>::position = markpt;
if (markpt == StreamBase<T>::size) {
@@ -87,7 +87,7 @@
} else {
StreamBase<T>::status = Ok;
}
- return Ok;
+ return markpt;
}
} // end namespace jstreams
--- branches/work/kde4/playground/libs/archivereader/src/streams/subinputstream.cpp \
#535981:535982 @@ -33,11 +33,16 @@
position = input->mark(readlimit) - offset;
return position;
}
-StreamStatus
+int64_t
SubInputStream::reset() {
- StreamStatus s = input->reset();
- position = input->getPosition() - offset;
- return s;
+ position = input->reset();
+ if (position < 0) {
+ status = Error;
+ error = input->getError();
+ } else {
+ position -= offset;
+ }
+ return position;
}
int64_t
SubInputStream::skip(int64_t ntoskip) {
--- branches/work/kde4/playground/libs/archivereader/src/streams/subinputstream.h \
#535981:535982 @@ -13,7 +13,7 @@
SubInputStream(StreamBase<char> *input, int64_t size);
int32_t read(const char*& start, int32_t min, int32_t max);
int64_t mark(int32_t readlimit);
- StreamStatus reset();
+ int64_t reset();
int64_t skip(int64_t ntoskip);
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic