git-svn-id: svn://db.shs.com.ru/pip@71 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -49,8 +49,8 @@ bool PIFileTransfer::send(PIVector<PIFile::FileInfo> entries) {
|
|||||||
allEntries.back().dest_path = entries[i].name();
|
allEntries.back().dest_path = entries[i].name();
|
||||||
if (entries[i].isDir()) {
|
if (entries[i].isDir()) {
|
||||||
PIDir d(entries[i].path);
|
PIDir d(entries[i].path);
|
||||||
d.up();
|
|
||||||
PIVector<PIFile::FileInfo> fls = d.allEntries();
|
PIVector<PIFile::FileInfo> fls = d.allEntries();
|
||||||
|
d.up();
|
||||||
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);
|
||||||
@@ -70,7 +70,7 @@ bool PIFileTransfer::sendFiles(const PIVector<PFTFileInfo> &files) {
|
|||||||
if (names.contains(files_[i].path)) {files_.remove(i); i--;}
|
if (names.contains(files_[i].path)) {files_.remove(i); i--;}
|
||||||
else names << files_[i].path;
|
else names << files_[i].path;
|
||||||
if (files_[i].isDir()) files_[i].size = 0;
|
if (files_[i].isDir()) files_[i].size = 0;
|
||||||
// piCout << "prepare" << i << files_[i].path << files_[i].size;
|
// piCout << "prepare" << i << files_[i].path << files_[i].dest_path << files_[i].name();
|
||||||
}
|
}
|
||||||
srand(PISystemTime::current().toMilliseconds());
|
srand(PISystemTime::current().toMilliseconds());
|
||||||
pftheader.session_id = rand();
|
pftheader.session_id = rand();
|
||||||
@@ -93,13 +93,13 @@ bool PIFileTransfer::sendFiles(const PIVector<PFTFileInfo> &files) {
|
|||||||
|
|
||||||
|
|
||||||
void PIFileTransfer::processFile(int id, ullong start, PIByteArray & data) {
|
void PIFileTransfer::processFile(int id, ullong start, PIByteArray & data) {
|
||||||
// piCout << "processFile" << id << files_.size();
|
piCout << "processFile" << id << files_.size();
|
||||||
PIFile::FileInfo fi = files_[id-1];
|
PFTFileInfo fi = files_[id-1];
|
||||||
bytes_file_all = fi.size;
|
bytes_file_all = fi.size;
|
||||||
bytes_file_cur = start;
|
bytes_file_cur = start;
|
||||||
cur_file_string = fi.path;
|
cur_file_string = fi.dest_path;
|
||||||
PIString path = dir.absolutePath() + dir.separator + fi.path;
|
PIString path = dir.absolutePath() + dir.separator + fi.dest_path;
|
||||||
// piCout << "receive" << path << fi.size << data.size();
|
piCout << "receive" << path << fi.size << data.size();
|
||||||
if (fi.isDir()) {
|
if (fi.isDir()) {
|
||||||
// piCoutObj << "make dir" << fi.entry.path;
|
// piCoutObj << "make dir" << fi.entry.path;
|
||||||
if (!PIDir::make(path)) {
|
if (!PIDir::make(path)) {
|
||||||
@@ -254,7 +254,8 @@ void PIFileTransfer::receive_finished(bool ok) {
|
|||||||
if (ok) {
|
if (ok) {
|
||||||
desc >> files_;
|
desc >> files_;
|
||||||
PIStringList files;
|
PIStringList files;
|
||||||
piForeachC(PIFile::FileInfo &fi, files_) files << fi.path;
|
piForeachC(PFTFileInfo &fi, files_) files << fi.dest_path;
|
||||||
|
// piCout << files;
|
||||||
receiveFilesRequest(files, bytesAll(), &user_ok);
|
receiveFilesRequest(files, bytesAll(), &user_ok);
|
||||||
}
|
}
|
||||||
if (!ok || !user_ok) {
|
if (!ok || !user_ok) {
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ public:
|
|||||||
quet_ = false;
|
quet_ = false;
|
||||||
eth.setReadAddress(src_ip_port);
|
eth.setReadAddress(src_ip_port);
|
||||||
eth.setSendAddress(dst_ip_port);
|
eth.setSendAddress(dst_ip_port);
|
||||||
//ft.setPacketSize(65000);
|
ft.setPacketSize(8192);
|
||||||
|
ft.setName("PIFT");
|
||||||
CONNECTU(&ft, sendRequest, this, ftsend);
|
CONNECTU(&ft, sendRequest, this, ftsend);
|
||||||
CONNECTU(&ft, sendFilesStarted, this, ftevent);
|
CONNECTU(&ft, sendFilesStarted, this, ftevent);
|
||||||
CONNECTU(&ft, receiveFilesStarted, this, ftevent);
|
CONNECTU(&ft, receiveFilesStarted, this, ftevent);
|
||||||
@@ -39,6 +40,10 @@ private:
|
|||||||
void tick(void *, int) {
|
void tick(void *, int) {
|
||||||
if (ft.isSending() || ft.isReceiving()) {
|
if (ft.isSending() || ft.isReceiving()) {
|
||||||
ftevent();
|
ftevent();
|
||||||
|
if (PIKbdListener::exiting) {
|
||||||
|
ft.stopSend();
|
||||||
|
ft.stopReceive();
|
||||||
|
}
|
||||||
// piCout << (int)ft.diagnostic().quality();
|
// piCout << (int)ft.diagnostic().quality();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -71,8 +76,9 @@ private:
|
|||||||
void usage() {
|
void usage() {
|
||||||
piCout << Bold << "PIP UDP file transfer";
|
piCout << Bold << "PIP UDP file transfer";
|
||||||
piCout << Cyan << "Version" << Bold << PIPVersion() << NewLine;
|
piCout << Cyan << "Version" << Bold << PIPVersion() << NewLine;
|
||||||
piCout << Green << Bold << "Usage:" << Default << "\"pift [-hq] -r <receive_ip> -s <send_ip> [-d <work_dir>] [-p port] [<path1>] [<path2>] [<path3>] [...]\"" << NewLine;
|
piCout << Green << Bold << "Usage:" << Default << "\"pift [-hqf] -r <receive_ip> -s <send_ip> [-d <work_dir>] [-p port] [<path1>] [<path2>] [<path3>] [...]\"" << NewLine;
|
||||||
piCout << Green << Bold << "Details:";
|
piCout << Green << Bold << "Details:";
|
||||||
|
piCout << "-f " << Green << "- full path in <receive_ip> and <send_ip>";
|
||||||
piCout << "-h " << Green << "- display this message and exit";
|
piCout << "-h " << Green << "- display this message and exit";
|
||||||
piCout << "-q " << Green << "- quiet, no debug output to console";
|
piCout << "-q " << Green << "- quiet, no debug output to console";
|
||||||
piCout << "-r " << Green << "- set receive ip address, must be ip address of this computer";
|
piCout << "-r " << Green << "- set receive ip address, must be ip address of this computer";
|
||||||
@@ -92,7 +98,8 @@ int main (int argc, char * argv[]) {
|
|||||||
cli.addArgument("port", true);
|
cli.addArgument("port", true);
|
||||||
cli.addArgument("help");
|
cli.addArgument("help");
|
||||||
cli.addArgument("quet");
|
cli.addArgument("quet");
|
||||||
if (!cli.hasArgument("send") || !cli.hasArgument("receive") || cli.hasArgument("help")) {
|
cli.addArgument("fullpath");
|
||||||
|
if ((!cli.hasArgument("send") || !cli.hasArgument("receive")) || cli.hasArgument("help")) {
|
||||||
usage();
|
usage();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -101,10 +108,12 @@ int main (int argc, char * argv[]) {
|
|||||||
int port = -1;
|
int port = -1;
|
||||||
if (cli.hasArgument("port")) port = cli.argumentValue("port").toInt();
|
if (cli.hasArgument("port")) port = cli.argumentValue("port").toInt();
|
||||||
if (port <=0) port = 50005;
|
if (port <=0) port = 50005;
|
||||||
PIKbdListener kbd;
|
if (!cli.hasArgument("fullpath")) {
|
||||||
kbd.enableExitCapture();
|
|
||||||
src += ":"+PIString::fromNumber(port);
|
src += ":"+PIString::fromNumber(port);
|
||||||
dst += ":"+PIString::fromNumber(port);
|
dst += ":"+PIString::fromNumber(port);
|
||||||
|
}
|
||||||
|
PIKbdListener kbd;
|
||||||
|
kbd.enableExitCapture();
|
||||||
UDPFileTransfer f(src, dst);
|
UDPFileTransfer f(src, dst);
|
||||||
if (cli.hasArgument("dir")) f.ft.setDirectory(cli.argumentValue("dir"));
|
if (cli.hasArgument("dir")) f.ft.setDirectory(cli.argumentValue("dir"));
|
||||||
if (cli.hasArgument("quet")) f.setQuet(true);
|
if (cli.hasArgument("quet")) f.setQuet(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user