PIFile::readAll release
patch deploy_tool: ignore libc.so and take last dpkg dependency instead of first
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -225,10 +225,7 @@ public:
|
||||
|
||||
//! \~english Read all file content to byte array and return it. Position leaved unchanged
|
||||
//! \~russian Читает всё содержимое файла и возвращает его как массив байтов. Позиция остаётся неизменной
|
||||
PIByteArray readAll(bool forceRead = false);
|
||||
|
||||
PIByteArray _readAll();
|
||||
|
||||
PIByteArray readAll();
|
||||
|
||||
//! \~english Set file path to "path" and reopen file if need
|
||||
//! \~russian Устанавливает путь файла на "path" и переоткрывает его при необходимости
|
||||
@@ -297,7 +294,7 @@ public:
|
||||
|
||||
//! \~english Read all file content at path "path" to byte array and return it.
|
||||
//! \~russian Читает всё содержимое файла по пути "path" и возвращает его как массив байтов.
|
||||
static PIByteArray readAll(const PIString & path, bool forceRead = false);
|
||||
static PIByteArray readAll(const PIString & path);
|
||||
|
||||
//! \~english Clear file at path "path" and write "data", returns written bytes.
|
||||
//! \~russian Очищает файл по пути "path", пишет туда "data" и возвращает количество записанных байт.
|
||||
|
||||
@@ -234,7 +234,7 @@ PIString PISystemInfo::machineKey() {
|
||||
PISystemInfo * si = instance();
|
||||
PIByteArray salt;
|
||||
PIString conf = confDir() + "/.pip_machine_salt";
|
||||
if (PIFile::isExists(conf)) salt = PIFile::readAll(conf, false);
|
||||
if (PIFile::isExists(conf)) salt = PIFile::readAll(conf);
|
||||
if (salt.size_s() != SALT_SIZE) {
|
||||
salt = generateSalt();
|
||||
PIFile::writeAll(conf, salt);
|
||||
|
||||
Reference in New Issue
Block a user