PIChar ICU fixes
git-svn-id: svn://db.shs.com.ru/pip@95 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -110,27 +110,47 @@ PIChar PIChar::fromUTF8(const char * c) {
|
|||||||
|
|
||||||
|
|
||||||
bool PIChar::operator ==(const PIChar & o) const {
|
bool PIChar::operator ==(const PIChar & o) const {
|
||||||
return strcmp(o.toCharPtr(), toCharPtr()) == 0;
|
return ch == o.ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PIChar::operator >(const PIChar & o) const {
|
bool PIChar::operator >(const PIChar & o) const {
|
||||||
return strcmp(o.toCharPtr(), toCharPtr()) < 0;
|
return
|
||||||
|
#ifdef PIP_ICU
|
||||||
|
u_strCompare((const UChar*)&(ch), 1, (const UChar*)&(o.ch), 1, FALSE) > 0;
|
||||||
|
#else
|
||||||
|
strcmp(toCharPtr(), o.toCharPtr()) > 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PIChar::operator <(const PIChar & o) const {
|
bool PIChar::operator <(const PIChar & o) const {
|
||||||
return strcmp(o.toCharPtr(), toCharPtr()) > 0;
|
return
|
||||||
|
#ifdef PIP_ICU
|
||||||
|
u_strCompare((const UChar*)&(ch), 1, (const UChar*)&(o.ch), 1, FALSE) < 0;
|
||||||
|
#else
|
||||||
|
strcmp(toCharPtr(), o.toCharPtr()) < 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PIChar::operator >=(const PIChar & o) const {
|
bool PIChar::operator >=(const PIChar & o) const {
|
||||||
return strcmp(o.toCharPtr(), toCharPtr()) <= 0;
|
return
|
||||||
|
#ifdef PIP_ICU
|
||||||
|
u_strCompare((const UChar*)&(ch), 1, (const UChar*)&(o.ch), 1, FALSE) >= 0;
|
||||||
|
#else
|
||||||
|
strcmp(toCharPtr(), o.toCharPtr()) >= 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PIChar::operator <=(const PIChar & o) const {
|
bool PIChar::operator <=(const PIChar & o) const {
|
||||||
return strcmp(o.toCharPtr(), toCharPtr()) >= 0;
|
return
|
||||||
|
#ifdef PIP_ICU
|
||||||
|
u_strCompare((const UChar*)&(ch), 1, (const UChar*)&(o.ch), 1, FALSE) <= 0;
|
||||||
|
#else
|
||||||
|
strcmp(toCharPtr(), o.toCharPtr()) <= 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -217,12 +237,26 @@ char PIChar::toConcole1Byte() const {
|
|||||||
|
|
||||||
|
|
||||||
PIChar PIChar::toUpper() const {
|
PIChar PIChar::toUpper() const {
|
||||||
|
#ifdef PIP_ICU
|
||||||
|
UChar c(0);
|
||||||
|
UErrorCode e((UErrorCode)0);
|
||||||
|
u_strToUpper(&c, 1, (const UChar*)(&ch), 1, 0, &e);
|
||||||
|
return PIChar(c);
|
||||||
|
#else
|
||||||
return PIChar(toupper(ch));
|
return PIChar(toupper(ch));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PIChar PIChar::toLower() const {
|
PIChar PIChar::toLower() const {
|
||||||
|
#ifdef PIP_ICU
|
||||||
|
UChar c(0);
|
||||||
|
UErrorCode e((UErrorCode)0);
|
||||||
|
u_strToLower(&c, 1, (const UChar*)(&ch), 1, 0, &e);
|
||||||
|
return PIChar(c);
|
||||||
|
#else
|
||||||
return PIChar(tolower(ch));
|
return PIChar(tolower(ch));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -237,6 +271,18 @@ std::ostream & operator <<(std::ostream & s, const PIChar & v) {
|
|||||||
PICout operator <<(PICout s, const PIChar & v) {
|
PICout operator <<(PICout s, const PIChar & v) {
|
||||||
s.space();
|
s.space();
|
||||||
s.setControl(0, true);
|
s.setControl(0, true);
|
||||||
|
#ifdef PIP_ICU
|
||||||
|
UErrorCode e((UErrorCode)0);
|
||||||
|
UConverter * cc = ucnv_open(PICout::isBufferActive() ? __syslocname__ : __sysoemname__, &e);
|
||||||
|
if (cc) {
|
||||||
|
char uc[8];
|
||||||
|
memset(uc, 0, 8);
|
||||||
|
e = (UErrorCode)0;
|
||||||
|
ucnv_fromUChars(cc, uc, 8, (const UChar*)(&v.ch), 1, &e);
|
||||||
|
ucnv_close(cc);
|
||||||
|
s << uc;
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
s << v.toCharPtr();
|
s << v.toCharPtr();
|
||||||
s.restoreControl();
|
s.restoreControl();
|
||||||
return s;
|
return s;
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ class PIP_EXPORT PIChar
|
|||||||
friend class PIString;
|
friend class PIString;
|
||||||
friend PIByteArray & operator <<(PIByteArray & s, const PIChar & v);
|
friend PIByteArray & operator <<(PIByteArray & s, const PIChar & v);
|
||||||
friend PIByteArray & operator >>(PIByteArray & s, PIChar & v);
|
friend PIByteArray & operator >>(PIByteArray & s, PIChar & v);
|
||||||
|
friend PICout operator <<(PICout s, const PIChar & v);
|
||||||
public:
|
public:
|
||||||
//! Contructs ascii symbol
|
//! Contructs ascii symbol
|
||||||
PIChar(const char c) {ch = c; ch &= 0xFF;}
|
PIChar(const char c) {ch = c; ch &= 0xFF;}
|
||||||
|
|||||||
@@ -149,6 +149,7 @@ PIDir & PIDir::cleanPath() {
|
|||||||
PIString PIDir::relative(const PIString & path) const {
|
PIString PIDir::relative(const PIString & path) const {
|
||||||
PIDir td(path);
|
PIDir td(path);
|
||||||
PIStringList dl(absolutePath().split(separator)), pl(td.absolutePath().split(separator)), rl;
|
PIStringList dl(absolutePath().split(separator)), pl(td.absolutePath().split(separator)), rl;
|
||||||
|
//piCout << pl << "rel to" << dl;
|
||||||
while (!dl.isEmpty() && !pl.isEmpty()) {
|
while (!dl.isEmpty() && !pl.isEmpty()) {
|
||||||
if (dl.front() != pl.front()) break;
|
if (dl.front() != pl.front()) break;
|
||||||
dl.pop_front();
|
dl.pop_front();
|
||||||
|
|||||||
@@ -54,9 +54,12 @@ bool PIFileTransfer::send(PIVector<PIFile::FileInfo> entries) {
|
|||||||
PIVector<PIFile::FileInfo> fls = d.allEntries();
|
PIVector<PIFile::FileInfo> fls = d.allEntries();
|
||||||
scanning = false;
|
scanning = false;
|
||||||
d.up();
|
d.up();
|
||||||
|
//piCout << "files rel to" << d.absolutePath();
|
||||||
for (int j = 0; j < fls.size(); j++) {
|
for (int j = 0; j < fls.size(); j++) {
|
||||||
allEntries << PFTFileInfo(fls[j]);
|
allEntries << PFTFileInfo(fls[j]);
|
||||||
allEntries.back().dest_path = d.relative(fls[j].path);
|
allEntries.back().dest_path = d.relative(fls[j].path);
|
||||||
|
//piCout << " abs path" << fls[j].path;
|
||||||
|
//piCout << " rel path" << allEntries.back().dest_path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -119,7 +122,9 @@ void PIFileTransfer::processFile(int id, ullong start, PIByteArray & data) {
|
|||||||
}
|
}
|
||||||
if (fi.isFile()) {
|
if (fi.isFile()) {
|
||||||
if (work_file.path() != path || !work_file.isOpened()) {
|
if (work_file.path() != path || !work_file.isOpened()) {
|
||||||
|
//piCout << "file close";
|
||||||
work_file.close();
|
work_file.close();
|
||||||
|
//piCout << "new file" << path << work_file.path() << work_file.isOpened();
|
||||||
if (!work_file.open(path, PIIODevice::ReadWrite)) {
|
if (!work_file.open(path, PIIODevice::ReadWrite)) {
|
||||||
cur_file_string = "ERROR! while open file " + path;
|
cur_file_string = "ERROR! while open file " + path;
|
||||||
piCoutObj << cur_file_string;
|
piCoutObj << cur_file_string;
|
||||||
@@ -285,6 +290,7 @@ void PIFileTransfer::receive_finished(bool ok) {
|
|||||||
} else resume();
|
} else resume();
|
||||||
}
|
}
|
||||||
if (pftheader.step == pft_Data) {
|
if (pftheader.step == pft_Data) {
|
||||||
|
//piCout << "file close";
|
||||||
work_file.close();
|
work_file.close();
|
||||||
started_ = false;
|
started_ = false;
|
||||||
receiveFilesFinished(ok);
|
receiveFilesFinished(ok);
|
||||||
@@ -293,6 +299,7 @@ void PIFileTransfer::receive_finished(bool ok) {
|
|||||||
|
|
||||||
|
|
||||||
void PIFileTransfer::send_finished(bool ok) {
|
void PIFileTransfer::send_finished(bool ok) {
|
||||||
|
//piCout << "file close";
|
||||||
work_file.close();
|
work_file.close();
|
||||||
started_ = false;
|
started_ = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -358,6 +358,7 @@ void Daemon::fmActionRequest(bool remote_tile, FileManager::Action type, PIVaria
|
|||||||
case FileManager::Copy:
|
case FileManager::Copy:
|
||||||
if (remote_tile) {
|
if (remote_tile) {
|
||||||
PIByteArray ba;
|
PIByteArray ba;
|
||||||
|
//piCout << fm.selectedRemote();
|
||||||
ba << int(CopyFiles) << fm.selectedRemote();
|
ba << int(CopyFiles) << fm.selectedRemote();
|
||||||
r->ft.setDirectory(fm.localDir());
|
r->ft.setDirectory(fm.localDir());
|
||||||
send(conn_name, ba);
|
send(conn_name, ba);
|
||||||
@@ -515,7 +516,7 @@ void Daemon::dataReceived(const PIString & from, const PIByteArray & data) {
|
|||||||
ba >> dir;
|
ba >> dir;
|
||||||
r->dir_my.cd(dir);
|
r->dir_my.cd(dir);
|
||||||
r->ft.setDirectory(r->dir_my);
|
r->ft.setDirectory(r->dir_my);
|
||||||
piCout << "store to" << r->dir_my.absolutePath();
|
//piCout << "store to" << r->dir_my.absolutePath();
|
||||||
piCout << "cd to" << dir << ", abs =" << r->dir_my.absolutePath();
|
piCout << "cd to" << dir << ", abs =" << r->dir_my.absolutePath();
|
||||||
sendDirToRemote(r);
|
sendDirToRemote(r);
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user