version 2.98.0

remove PIFile::readLine()
partially migrate PIConfig to text stream
add more "override"
This commit is contained in:
2022-08-01 18:13:22 +03:00
parent 97734953dd
commit b0d48caaad
8 changed files with 127 additions and 156 deletions

View File

@@ -20,6 +20,7 @@
#include "piincludes_p.h"
#include "pifile.h"
#include "pidir.h"
#include "piiostream.h"
#include "pitime_win.h"
#ifdef WINDOWS
# undef S_IFDIR
@@ -229,24 +230,6 @@ bool PIFile::closeDevice() {
}
PIString PIFile::readLine() {
PIByteArray str;
if (isClosed()) return str;
int cc;
while (!isEnd()) {
cc = fgetc(PRIVATE->fd);
if (char(cc) == '\n' || cc == EOF) break;
str.push_back(char(cc));
}
str.push_back('\0');
if (defaultCharset()) {
return PIString::fromCodepage((const char *)str.data(), defaultCharset());
}
//cout << "readline: " << str << endl;
return PIString::fromUTF8(str);
}
llong PIFile::readAll(void * data) {
llong cp = pos(), s = size(), i = -1;
seekToBegin();
@@ -371,7 +354,6 @@ void PIFile::_init() {
PRIVATE->fd = 0;
fdi = -1;
_size = -1;
setPrecision(5);
}
@@ -405,7 +387,8 @@ void PIFile::seekToEnd() {
void PIFile::seekToLine(llong line) {
if (isClosed()) return;
seekToBegin();
piForTimes(line) readLine();
PIIOTextStream ts(this);
piForTimes (line) ts.readLine();
clearerr(PRIVATE->fd);
}
@@ -444,13 +427,6 @@ bool PIFile::isEnd() const {
}
void PIFile::setPrecision(int prec) {
prec_ = prec;
if (prec_ >= 0) prec_str = "." + PIString::fromNumber(prec_);
else prec_str = "";
}
PIFile & PIFile::put(const PIByteArray & v) {
int sz = (int)v.size_s();
write(createMemoryBlock(&sz));
@@ -500,16 +476,6 @@ void PIFile::remove() {
const char * PIFile::defaultCharset() {
return PIInit::instance()->file_charset;
}
void PIFile::setDefaultCharset(const char * c) {
PIInit::instance()->setFileCharset(c);
}
PIFile::FileInfo PIFile::fileInfo(const PIString & path) {
FileInfo ret;