summaryrefslogtreecommitdiff
path: root/cpp/src/IceGrid/FileCache.cpp
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2007-01-25 17:47:18 +0000
committerBenoit Foucher <benoit@zeroc.com>2007-01-25 17:47:18 +0000
commit66128a40663c6f6ccb85e44bfaea3a770e58de11 (patch)
tree09cd0c85be844c1a7509d4ec7b99b5a0e02b456c /cpp/src/IceGrid/FileCache.cpp
parentAutomatically set USE_STLPORT if CPP_COMPILER=VC60 (diff)
downloadice-66128a40663c6f6ccb85e44bfaea3a770e58de11.tar.bz2
ice-66128a40663c6f6ccb85e44bfaea3a770e58de11.tar.xz
ice-66128a40663c6f6ccb85e44bfaea3a770e58de11.zip
Fixed file reader
Diffstat (limited to 'cpp/src/IceGrid/FileCache.cpp')
-rw-r--r--cpp/src/IceGrid/FileCache.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/cpp/src/IceGrid/FileCache.cpp b/cpp/src/IceGrid/FileCache.cpp
index 4fbaffaf9ad..98d4030f2e6 100644
--- a/cpp/src/IceGrid/FileCache.cpp
+++ b/cpp/src/IceGrid/FileCache.cpp
@@ -148,7 +148,6 @@ FileCache::read(const string& file, Ice::Long offset, int size, Ice::Long& newOf
is.seekg(0, ios::end);
if(offset >= is.tellg())
{
-// cerr << "reading at EOF " << offset << " " << is.tellg() << endl;
newOffset = is.tellg();
lines = Ice::StringSeq();
return true;
@@ -159,15 +158,17 @@ FileCache::read(const string& file, Ice::Long offset, int size, Ice::Long& newOf
//
newOffset = offset;
lines = Ice::StringSeq();
+#if defined(_MSC_VER) && (_MSC_VER < 1300)
+ is.seekg(static_cast<int>(offset));
+#else
is.seekg(static_cast<streamoff>(offset), ios::beg);
+#endif
int totalSize = 0;
string line;
-// cerr << "starting read " << offset << endl;
for(int i = 0; is.good(); ++i)
{
getline(is, line);
-// cerr << "read " << " " << is.tellg() << " " << line << endl;
int lineSize = static_cast<int>(line.size()) + 5; // 5 bytes for the encoding of the string size (worst case)
if(lineSize + totalSize > size)
@@ -187,14 +188,21 @@ FileCache::read(const string& file, Ice::Long offset, int size, Ice::Long& newOf
}
totalSize += lineSize;
+ lines.push_back(line);
+#if defined(_MSC_VER) && (_MSC_VER < 1300)
+ if(is.eof())
+ {
+ newOffset += line.size();
+ }
+ else
+#else
if(!is.fail())
+#endif
{
newOffset = is.tellg();
}
- lines.push_back(line);
}
-// cerr << "finished read " << newOffset << " " << is.eof() << " " << lines.size()<< endl;
if(is.bad())
{
throw FileNotAvailableException("unrecoverable error occured while reading file `" + file + "'");