05.11.2011 - stable version, 0.1.0, self-test program, work at GCC 2.95 - 4.5, VC 2010, MinGW, Linux, Windows, QNX

This commit is contained in:
peri4
2011-12-05 23:51:02 +03:00
parent e25553b97b
commit 74b4173c4c
43 changed files with 1495 additions and 694 deletions

View File

@@ -23,18 +23,32 @@ PIString PIFile::readLine() {
llong PIFile::readAll(void * data) {
llong cp = pos(), s = size();
llong cp = pos(), s = size(), i = -1;
stream.seekg(0);
stream.read((char * )data, s);
if (s < 0) {
while (!stream.eof())
stream.read(&(((char*)data)[++i]), 1);
} else
stream.read((char * )data, s);
seek(cp);
return s;
}
PIByteArray PIFile::readAll() {
llong s = size();
if (s < 0) return PIByteArray();
PIByteArray a(s);
PIByteArray PIFile::readAll(bool forceRead) {
llong cp = pos(), s = size();
char c;
PIByteArray a;
if (s < 0) {
if (!forceRead) return a;
while (!stream.eof()) {
stream.read(&c, 1);
a.push_back(c);
}
seek(cp);
return a;
}
a.resize(s);
s = readAll(a.data());
if (s >= 0) a.resize(s);
return a;
@@ -47,6 +61,7 @@ llong PIFile::size() {
stream.seekg(0, fstream::end);
s = stream.tellg();
stream.seekg(cp, fstream::beg);
stream.clear();
return s;
}