git-svn-id: svn://db.shs.com.ru/pip@526 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -70,13 +70,17 @@ bool PIFileTransfer::send(PIVector<PIFile::FileInfo> entries) {
|
||||
bool PIFileTransfer::sendFiles(const PIVector<PFTFileInfo> &files) {
|
||||
files_ = files;
|
||||
PIStringList names;
|
||||
// piCoutObj << "prepare to send" << files_.size() << "files";
|
||||
for(int i=0; i<files_.size_s(); i++) {
|
||||
// files_[i].path = dir.relative(files_[i].path);
|
||||
if (names.contains(files_[i].path)) {files_.remove(i); i--;}
|
||||
//piCoutObj << "prepare to send" << files_.size() << "files";
|
||||
for (int i = 0; i < files_.size_s(); i++) {
|
||||
//files_[i].path = dir.relative(files_[i].path);
|
||||
if (names.contains(files_[i].path)) {
|
||||
files_.remove(i);
|
||||
--i;
|
||||
}
|
||||
else names << files_[i].path;
|
||||
if (files_[i].isDir()) files_[i].size = 0;
|
||||
// piCout << "prepare" << i << files_[i].path << files_[i].dest_path << files_[i].name();
|
||||
if (files_[i].isDir())
|
||||
files_[i].size = 0;
|
||||
//piCout << "prepare" << i << files_[i].path << files_[i].dest_path << files_[i].name();
|
||||
}
|
||||
randomize();
|
||||
step_mutex.lock();
|
||||
@@ -97,8 +101,8 @@ bool PIFileTransfer::sendFiles(const PIVector<PFTFileInfo> &files) {
|
||||
step_mutex.lock();
|
||||
pftheader.step = pft_Data;
|
||||
PIVector<Part> pts;
|
||||
for (int i=0; i<files_.size_s(); i++) {
|
||||
pts << Part(i+1, files_[i].size);
|
||||
for (int i = 0; i < files_.size_s(); i++) {
|
||||
pts << Part(i + 1, files_[i].size);
|
||||
}
|
||||
buildSession(pts);
|
||||
step_mutex.unlock();
|
||||
@@ -120,7 +124,7 @@ void PIFileTransfer::processFile(int id, ullong start, PIByteArray & data) {
|
||||
if (fi.isDir()) {
|
||||
//piCoutObj << "make dir" << fi.entry.path;
|
||||
if (!PIDir::make(path)) {
|
||||
cur_file_string = "ERROR! while create directory " + path;
|
||||
cur_file_string = "Error: While create directory \"" + path + "\"";
|
||||
piCoutObj << cur_file_string;
|
||||
stopReceive();
|
||||
return;
|
||||
@@ -132,7 +136,7 @@ void PIFileTransfer::processFile(int id, ullong start, PIByteArray & data) {
|
||||
work_file.close();
|
||||
//piCout << "new file" << path << work_file.path() << work_file.isOpened();
|
||||
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;
|
||||
stopReceive();
|
||||
return;
|
||||
@@ -161,7 +165,7 @@ void PIFileTransfer::processFile(int id, ullong start, PIByteArray & data) {
|
||||
work_file.seek(start);
|
||||
int rs = work_file.write(data.data(), data.size());
|
||||
if (rs != data.size_s()) {
|
||||
cur_file_string = "ERROR! while write file " + fi.path + " (must " + PIString::fromNumber(data.size()) + ", but write " + PIString::fromNumber(rs) + ")";
|
||||
cur_file_string = "Error: While write file \"" + fi.path + "\" (must " + PIString::fromNumber(data.size()) + ", but write " + PIString::fromNumber(rs) + ")";
|
||||
piCoutObj << cur_file_string;
|
||||
stopReceive();
|
||||
return;
|
||||
@@ -183,15 +187,15 @@ PIByteArray PIFileTransfer::buildPacket(Part p) {
|
||||
memcpy(ba.data(), desc.data(p.start), p.size);
|
||||
return ba;
|
||||
case pft_Data:
|
||||
// piCout << "send data" << p.id << files_.size();
|
||||
//piCout << "send data" << p.id << files_.size();
|
||||
PIFile::FileInfo fi = files_[p.id-1];
|
||||
if (fi.isFile()) {
|
||||
// piCout << "send file" << fi.name() << fi.size;
|
||||
//piCout << "send file" << fi.name() << fi.size;
|
||||
PIString path = fi.path;
|
||||
if (work_file.path() != path || !work_file.isOpened()) {
|
||||
if (!work_file.open(path, PIIODevice::ReadOnly)) {
|
||||
break_ = true;
|
||||
cur_file_string = "ERROR! while open file " + fi.path;
|
||||
cur_file_string = "Error: While open file \"" + fi.path + "\"";
|
||||
piCoutObj << cur_file_string;
|
||||
stopSend();
|
||||
return PIByteArray();
|
||||
@@ -202,16 +206,16 @@ PIByteArray PIFileTransfer::buildPacket(Part p) {
|
||||
int rs = work_file.read(ba.data(), ba.size());
|
||||
if ((llong)rs != (llong)p.size) {
|
||||
break_ = true;
|
||||
cur_file_string = "ERROR! while read file " + fi.path + " (must " + PIString::fromNumber(p.size) + ", but read " + PIString::fromNumber(rs) + ")";
|
||||
cur_file_string = "Error: While read file \"" + fi.path + "\" (must " + PIString::fromNumber(p.size) + ", but read " + PIString::fromNumber(rs) + ")";
|
||||
piCoutObj << cur_file_string;
|
||||
stopSend();
|
||||
return PIByteArray();
|
||||
}
|
||||
}
|
||||
// if (fi.isDir()) {
|
||||
// piCout << "create dir" << fi.path;
|
||||
// dir.make(fi.path);
|
||||
// }
|
||||
//if (fi.isDir()) {
|
||||
// piCout << "create dir" << fi.path;
|
||||
// dir.make(fi.path);
|
||||
//}
|
||||
cur_file_string = fi.path;
|
||||
bytes_file_all = fi.size;
|
||||
bytes_file_cur = p.start;
|
||||
@@ -230,7 +234,7 @@ void PIFileTransfer::receivePart(PIBaseTransfer::Part fi, PIByteArray ba, PIByte
|
||||
StepType st = (StepType)h.step;
|
||||
pftheader.step = st;
|
||||
if (!h.check_sig()) {
|
||||
cur_file_string = "ERROR check signature: File Transfer incompatable or invalid version!";
|
||||
cur_file_string = "Error: Check signature: File Transfer incompatable or invalid version!";
|
||||
piCoutObj << cur_file_string;
|
||||
stopReceive();
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user