add PICli to pift
fix relative path in PIFileTransfer git-svn-id: svn://db.shs.com.ru/pip@67 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -43,22 +43,30 @@ bool PIFileTransfer::send(const PIStringList& files) {
|
||||
|
||||
|
||||
bool PIFileTransfer::send(PIVector<PIFile::FileInfo> entries) {
|
||||
PIVector<PIFile::FileInfo> allEntries;
|
||||
PIVector<PFTFileInfo> allEntries;
|
||||
for (int i = 0; i < entries.size_s(); i++) {
|
||||
allEntries << entries[i];
|
||||
if (entries[i].isDir())
|
||||
allEntries << PIDir::allEntries(entries[i].path);
|
||||
allEntries << PFTFileInfo(entries[i]);
|
||||
allEntries.back().dest_path = entries[i].name();
|
||||
if (entries[i].isDir()) {
|
||||
PIDir d(entries[i].path);
|
||||
d.up();
|
||||
PIVector<PIFile::FileInfo> fls = d.allEntries();
|
||||
for (int j=0; j<fls.size(); j++) {
|
||||
allEntries << PFTFileInfo(fls[j]);
|
||||
allEntries.back().dest_path = d.relative(fls[j].path);
|
||||
}
|
||||
}
|
||||
}
|
||||
return sendFiles(allEntries);
|
||||
}
|
||||
|
||||
|
||||
bool PIFileTransfer::sendFiles(const PIVector<PIFile::FileInfo> &files) {
|
||||
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);
|
||||
// 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;
|
||||
@@ -159,7 +167,7 @@ PIByteArray PIFileTransfer::buildPacket(Part p) {
|
||||
PIFile::FileInfo fi = files_[p.id-1];
|
||||
if (fi.isFile()) {
|
||||
// piCout << "send file" << fi.name() << fi.size;
|
||||
PIString path = dir.absolutePath() + dir.separator + fi.path;
|
||||
PIString path = fi.path;
|
||||
if (work_file.path() != path || !work_file.isOpened()) {
|
||||
if (!work_file.open(path, PIIODevice::ReadOnly)) {
|
||||
break_ = true;
|
||||
|
||||
Reference in New Issue
Block a user