some PIFile functionality

PIBinaryLog::close fix
This commit is contained in:
2022-12-26 14:09:05 +03:00
parent 81cbf905ba
commit f355cfc05e
6 changed files with 27 additions and 1 deletions

View File

@@ -156,7 +156,7 @@ bool PIBinaryLog::openDevice() {
bool PIBinaryLog::closeDevice() {
stopThreadedRead();
stopAndWait();
pausemutex.unlock();
logmutex.unlock();
moveIndex(-1);

View File

@@ -160,6 +160,16 @@ PIDir & PIDir::cleanPath() {
PIString PIDir::relative(const PIString & path) const {
PIDir td(path);
PIStringList dl(absolutePath().split(separator)), pl(td.absolutePath().split(separator)), rl;
auto checkPath = [](PIStringList & path) {
if (path.isEmpty()) return;
if (path[0].size() >= 2) {
if (path[0][0].isAlpha() && path[0][1] == ':') {
path[0][0] = path[0][0].toUpper();
}
}
};
checkPath(dl);
checkPath(pl);
// piCout << pl << "rel to" << dl;
while (!dl.isEmpty() && !pl.isEmpty()) {
if (dl.front() != pl.front()) break;

View File

@@ -153,6 +153,16 @@ PIString PIFile::FileInfo::dir() const {
}
bool PIFile::FileInfo::isAbsolute() const {
if (path.isEmpty()) return false;
if (path[0] == '/') return true;
if (path.size() >= 2) {
if (path[0].isAlpha() && path[1] == ':') return true;
}
return false;
}
PIFile::PIFile(): PIIODevice() {}

View File

@@ -179,6 +179,10 @@ public:
//! \~english Returns if Hidden flag set
//! \~russian Возвращает установлен ли флаг Hidden
bool isHidden() const { return flags[Hidden]; }
//! \~english Returns if path is absolute
//! \~russian Возвращает абсолютный ли путь
bool isAbsolute() const;
};

View File

@@ -34,6 +34,7 @@
const char PIValueTree::Attribute::hidden [] = "hidden" ;
const char PIValueTree::Attribute::readOnly [] = "readOnly" ;
const char PIValueTree::Attribute::isLabel [] = "label" ;
const char PIValueTree::Attribute::grouping [] = "grouping" ;
const char PIValueTree::Attribute::arrayType [] = "arrayType" ;
const char PIValueTree::Attribute::arrayMinCount[] = "arrayMinCount";

View File

@@ -44,6 +44,7 @@ public:
static const char hidden [];
static const char readOnly [];
static const char isLabel [];
static const char grouping [];
static const char arrayType [];
static const char arrayMinCount[];