PIFile::readAll release

patch deploy_tool: ignore libc.so and take last dpkg dependency instead of first
This commit is contained in:
2025-09-05 21:46:44 +03:00
parent 91144ad338
commit a299ada873
5 changed files with 26 additions and 41 deletions

View File

@@ -252,32 +252,7 @@ llong PIFile::readAll(void * data) {
}
PIByteArray PIFile::readAll(bool forceRead) {
PIByteArray a;
llong cp = pos();
if (forceRead) {
seekToBegin();
for (;;) {
uchar byte = static_cast<uchar>(fgetc(PRIVATE->fd));
if (feof(PRIVATE->fd) || ferror(PRIVATE->fd)) break;
a.push_back(byte);
}
seek(cp);
return a;
}
llong s = size();
if (s < 0) return a;
a.resize(s);
seekToBegin();
auto _r = fread(a.data(), 1, s, PRIVATE->fd);
NO_UNUSED(_r);
seek(cp);
if (s >= 0) a.resize(s);
return a;
}
PIByteArray PIFile::_readAll() {
PIByteArray PIFile::readAll() {
if (!isOpened()) return {};
llong prev_pos = pos();
PIByteArray ret, buffer(4_KiB);
@@ -647,10 +622,10 @@ bool PIFile::applyFileInfo(const PIString & path, const PIFile::FileInfo & info)
}
PIByteArray PIFile::readAll(const PIString & path, bool forceRead) {
PIByteArray PIFile::readAll(const PIString & path) {
PIFile f(path, PIIODevice::ReadOnly);
if (!f.isOpened()) return PIByteArray();
return f.readAll(forceRead);
return f.readAll();
}