Mercurial > gftp.yaz
comparison src/uicommon/gftpui.c @ 894:14476a8a4d2b
2007-3-15 Brian Masney <masneyb@gftp.org>
* src/gtk/transfer.c src/gtk/view_dialog.c - combined some duplicate
code that was used to view and edit files.
* lib/gftp.h src/gtk/transfer.c src/gtk/view_dialog.c
src/uicommon/gftpui.c - removed is_fd member from the gftp_file
structure.
author | masneyb |
---|---|
date | Fri, 16 Mar 2007 02:33:05 +0000 |
parents | 1808cebed602 |
children | 4ab11f70a7f4 |
comparison
equal
deleted
inserted
replaced
893:331d6ad73a75 | 894:14476a8a4d2b |
---|---|
1223 gftpui_start_transfer (tdata); | 1223 gftpui_start_transfer (tdata); |
1224 return (tdata); | 1224 return (tdata); |
1225 } | 1225 } |
1226 | 1226 |
1227 | 1227 |
1228 static void | |
1229 _gftpui_common_setup_fds (gftp_transfer * tdata, gftp_file * curfle, | |
1230 int *fromfd, int *tofd) | |
1231 { | |
1232 *tofd = -1; | |
1233 *fromfd = -1; | |
1234 | |
1235 if (curfle->is_fd) | |
1236 { | |
1237 if (tdata->toreq->protonum == GFTP_LOCAL_NUM) | |
1238 *tofd = curfle->fd; | |
1239 else if (tdata->fromreq->protonum == GFTP_LOCAL_NUM) | |
1240 *fromfd = curfle->fd; | |
1241 } | |
1242 } | |
1243 | |
1244 | |
1245 static void | |
1246 _gftpui_common_done_with_fds (gftp_transfer * tdata, gftp_file * curfle) | |
1247 { | |
1248 if (curfle->is_fd) | |
1249 { | |
1250 if (tdata->toreq->protonum == GFTP_LOCAL_NUM) | |
1251 tdata->toreq->datafd = -1; | |
1252 else | |
1253 tdata->fromreq->datafd = -1; | |
1254 } | |
1255 } | |
1256 | |
1257 | |
1258 static ssize_t | 1228 static ssize_t |
1259 _do_transfer_block (gftp_transfer * tdata, gftp_file * curfle, char *buf, | 1229 _do_transfer_block (gftp_transfer * tdata, gftp_file * curfle, char *buf, |
1260 size_t trans_blksize) | 1230 size_t trans_blksize) |
1261 { | 1231 { |
1262 ssize_t num_read, num_wrote, ret; | 1232 ssize_t num_read, num_wrote, ret; |
1449 | 1419 |
1450 | 1420 |
1451 static int | 1421 static int |
1452 _gftpui_common_trans_file_or_dir (gftp_transfer * tdata) | 1422 _gftpui_common_trans_file_or_dir (gftp_transfer * tdata) |
1453 { | 1423 { |
1454 int tofd, fromfd, ret; | |
1455 gftp_file * curfle; | 1424 gftp_file * curfle; |
1425 int ret; | |
1456 | 1426 |
1457 if (g_thread_supported ()) | 1427 if (g_thread_supported ()) |
1458 g_static_mutex_lock (&tdata->structmutex); | 1428 g_static_mutex_lock (&tdata->structmutex); |
1459 | 1429 |
1460 curfle = tdata->curfle->data; | 1430 curfle = tdata->curfle->data; |
1480 tdata->tot_file_trans = 0; | 1450 tdata->tot_file_trans = 0; |
1481 ret = gftp_make_directory (tdata->toreq, curfle->destfile); | 1451 ret = gftp_make_directory (tdata->toreq, curfle->destfile); |
1482 } | 1452 } |
1483 else | 1453 else |
1484 { | 1454 { |
1485 _gftpui_common_setup_fds (tdata, curfle, &fromfd, &tofd); | |
1486 | |
1487 if (curfle->size == 0) | 1455 if (curfle->size == 0) |
1488 { | 1456 { |
1489 curfle->size = gftp_get_file_size (tdata->fromreq, curfle->file); | 1457 curfle->size = gftp_get_file_size (tdata->fromreq, curfle->file); |
1490 if (curfle->size < 0) | 1458 if (curfle->size < 0) |
1491 return ((int) curfle->size); | 1459 return ((int) curfle->size); |
1500 if (curfle->startsize < 0) | 1468 if (curfle->startsize < 0) |
1501 return ((int) curfle->startsize); | 1469 return ((int) curfle->startsize); |
1502 } | 1470 } |
1503 | 1471 |
1504 tdata->tot_file_trans = gftp_transfer_file (tdata->fromreq, curfle->file, | 1472 tdata->tot_file_trans = gftp_transfer_file (tdata->fromreq, curfle->file, |
1505 fromfd, | 1473 0, |
1506 curfle->transfer_action == GFTP_TRANS_ACTION_RESUME ? | 1474 curfle->transfer_action == GFTP_TRANS_ACTION_RESUME ? |
1507 curfle->startsize : 0, | 1475 curfle->startsize : 0, |
1508 tdata->toreq, curfle->destfile, tofd, | 1476 tdata->toreq, curfle->destfile, 0, |
1509 curfle->transfer_action == GFTP_TRANS_ACTION_RESUME ? | 1477 curfle->transfer_action == GFTP_TRANS_ACTION_RESUME ? |
1510 curfle->startsize : 0); | 1478 curfle->startsize : 0); |
1511 if (tdata->tot_file_trans < 0) | 1479 if (tdata->tot_file_trans < 0) |
1512 ret = tdata->tot_file_trans; | 1480 ret = tdata->tot_file_trans; |
1513 else | 1481 else |
1522 if (g_thread_supported ()) | 1490 if (g_thread_supported ()) |
1523 g_static_mutex_unlock (&tdata->structmutex); | 1491 g_static_mutex_unlock (&tdata->structmutex); |
1524 | 1492 |
1525 ret = _gftpui_common_do_transfer_file (tdata, curfle); | 1493 ret = _gftpui_common_do_transfer_file (tdata, curfle); |
1526 } | 1494 } |
1527 | |
1528 _gftpui_common_done_with_fds (tdata, curfle); | |
1529 } | 1495 } |
1530 | 1496 |
1531 if (ret == 0) | 1497 if (ret == 0) |
1532 { | 1498 ret = _gftpui_common_preserve_perm_time (tdata, curfle); |
1533 if (!curfle->is_fd) | |
1534 ret = _gftpui_common_preserve_perm_time (tdata, curfle); | |
1535 } | |
1536 else | 1499 else |
1537 { | 1500 { |
1538 curfle->retry_transfer = 1; | 1501 curfle->retry_transfer = 1; |
1539 tdata->fromreq->logging_function (gftp_logging_error, tdata->fromreq, | 1502 tdata->fromreq->logging_function (gftp_logging_error, tdata->fromreq, |
1540 _("Could not download %s from %s\n"), | 1503 _("Could not download %s from %s\n"), |