diff -pru mc-4.6.1-orig/src/file.c mc-4.6.1/src/file.c
old
|
new
|
copy_file_file (FileOpContext *ctx, cons |
548 | 548 | S_ISSOCK (sb.st_mode)) { |
549 | 549 | while (mc_mknod (dst_path, sb.st_mode & ctx->umask_kill, |
550 | 550 | sb.st_rdev) < 0) { |
| 551 | if ( ctx->skip_all ) |
| 552 | break; |
551 | 553 | return_status = file_error ( |
552 | 554 | _(" Cannot create special file \"%s\" \n %s "), dst_path); |
553 | 555 | if (return_status == FILE_RETRY) |
554 | 556 | continue; |
| 557 | if (return_status == FILE_SKIPALL) |
| 558 | ctx->skip_all = 1; |
| 559 | if (return_status == FILE_SKIP); |
555 | 560 | return return_status; |
556 | 561 | } |
557 | 562 | /* Success */ |
558 | 563 | |
559 | 564 | while (ctx->preserve_uidgid |
560 | 565 | && mc_chown (dst_path, sb.st_uid, sb.st_gid)) { |
| 566 | if ( ctx->skip_all ) |
| 567 | break; |
561 | 568 | temp_status = file_error ( |
562 | 569 | _(" Cannot chown target file \"%s\" \n %s "), dst_path); |
| 570 | if (temp_status == FILE_SKIPALL) |
| 571 | ctx->skip_all = 1; |
| 572 | if (temp_status == FILE_SKIP) |
| 573 | break; |
563 | 574 | if (temp_status == FILE_RETRY) |
564 | 575 | continue; |
565 | 576 | return temp_status; |
566 | 577 | } |
567 | 578 | while (ctx->preserve && |
568 | 579 | mc_chmod (dst_path, sb.st_mode & ctx->umask_kill)) { |
| 580 | if ( ctx->skip_all ) |
| 581 | break; |
569 | 582 | temp_status = file_error ( |
570 | 583 | _(" Cannot chmod target file \"%s\" \n %s "), dst_path); |
| 584 | if (temp_status == FILE_SKIPALL) |
| 585 | ctx->skip_all = 1; |
| 586 | if (temp_status == FILE_SKIP) |
| 587 | break; |
571 | 588 | if (temp_status == FILE_RETRY) |
572 | 589 | continue; |
573 | 590 | return temp_status; |
… |
… |
copy_file_file (FileOpContext *ctx, cons |
579 | 596 | gettimeofday (&tv_transfer_start, (struct timezone *) NULL); |
580 | 597 | |
581 | 598 | while ((src_desc = mc_open (src_path, O_RDONLY | O_LINEAR)) < 0) { |
| 599 | if ( ctx->skip_all ) |
| 600 | break; |
582 | 601 | return_status = file_error ( |
583 | 602 | _(" Cannot open source file \"%s\" \n %s "), src_path); |
584 | 603 | if (return_status == FILE_RETRY) |
585 | 604 | continue; |
| 605 | if (return_status == FILE_SKIPALL) |
| 606 | ctx->skip_all = 1; |
| 607 | if (return_status == FILE_SKIP) |
| 608 | break; |
586 | 609 | ctx->do_append = 0; |
587 | 610 | return return_status; |
588 | 611 | } |
… |
… |
copy_file_file (FileOpContext *ctx, cons |
596 | 619 | } |
597 | 620 | |
598 | 621 | while (mc_fstat (src_desc, &sb)) { |
| 622 | if ( ctx->skip_all ) |
| 623 | goto ret; |
599 | 624 | return_status = file_error ( |
600 | 625 | _(" Cannot fstat source file \"%s\" \n %s "), src_path); |
601 | 626 | if (return_status == FILE_RETRY) |
602 | 627 | continue; |
| 628 | if (return_status == FILE_SKIPALL) |
| 629 | ctx->skip_all = 1; |
| 630 | if (return_status == FILE_SKIP); |
603 | 631 | ctx->do_append = 0; |
604 | 632 | goto ret; |
605 | 633 | } |
… |
… |
copy_file_file (FileOpContext *ctx, cons |
616 | 644 | |
617 | 645 | while ((dest_desc = mc_open (dst_path, O_WRONLY | (ctx->do_append ? |
618 | 646 | O_APPEND : (O_CREAT | O_TRUNC)), 0600)) < 0) { |
| 647 | if ( ctx->skip_all ) |
| 648 | goto ret; |
619 | 649 | return_status = file_error ( |
620 | 650 | _(" Cannot create target file \"%s\" \n %s "), dst_path); |
621 | 651 | if (return_status == FILE_RETRY) |
622 | 652 | continue; |
| 653 | if (return_status == FILE_SKIPALL) |
| 654 | ctx->skip_all = 1; |
| 655 | if (return_status == FILE_SKIP); |
623 | 656 | ctx->do_append = 0; |
624 | 657 | goto ret; |
625 | 658 | } |
… |
… |
copy_file_file (FileOpContext *ctx, cons |
630 | 663 | |
631 | 664 | /* Find out the optimal buffer size. */ |
632 | 665 | while (mc_fstat (dest_desc, &sb)) { |
| 666 | if ( ctx->skip_all ) |
| 667 | goto ret; |
633 | 668 | return_status = file_error ( |
634 | 669 | _(" Cannot fstat target file \"%s\" \n %s "), dst_path); |
635 | 670 | if (return_status == FILE_RETRY) |
636 | 671 | continue; |
| 672 | if (return_status == FILE_SKIPALL) |
| 673 | ctx->skip_all = 1; |
| 674 | if (return_status == FILE_SKIP); |
637 | 675 | goto ret; |
638 | 676 | } |
639 | 677 | buf = g_malloc (buf_size); |
… |
… |
copy_file_file (FileOpContext *ctx, cons |
662 | 700 | n_read = -1; |
663 | 701 | else |
664 | 702 | while ((n_read = mc_read (src_desc, buf, buf_size)) < 0) { |
| 703 | if ( ctx->skip_all ) |
| 704 | goto ret; |
665 | 705 | return_status = file_error ( |
666 | 706 | _(" Cannot read source file \"%s\" \n %s "), src_path); |
667 | 707 | if (return_status == FILE_RETRY) |
668 | 708 | continue; |
| 709 | if (return_status == FILE_SKIPALL) |
| 710 | ctx->skip_all = 1; |
| 711 | if (return_status == FILE_SKIP); |
669 | 712 | goto ret; |
670 | 713 | } |
671 | 714 | if (n_read == 0) |
… |
… |
copy_file_file (FileOpContext *ctx, cons |
688 | 731 | /* dst_write */ |
689 | 732 | while ((n_written = |
690 | 733 | mc_write (dest_desc, t, n_read)) < n_read) { |
| 734 | if ( ctx->skip_all ) |
| 735 | break; |
691 | 736 | if (n_written > 0) { |
692 | 737 | n_read -= n_written; |
693 | 738 | t += n_written; |
… |
… |
copy_file_file (FileOpContext *ctx, cons |
698 | 743 | dst_path); |
699 | 744 | if (return_status != FILE_RETRY) |
700 | 745 | goto ret; |
| 746 | if (return_status == FILE_SKIPALL) |
| 747 | ctx->skip_all = 1; |
| 748 | if (return_status == FILE_SKIP) |
| 749 | break; |
701 | 750 | } |
702 | 751 | } |
703 | 752 | |
… |
… |
copy_file_file (FileOpContext *ctx, cons |
755 | 804 | g_free (buf); |
756 | 805 | |
757 | 806 | while (src_desc != -1 && mc_close (src_desc) < 0) { |
| 807 | if ( ctx->skip_all ) |
| 808 | break; |
758 | 809 | temp_status = file_error ( |
759 | 810 | _(" Cannot close source file \"%s\" \n %s "), src_path); |
760 | 811 | if (temp_status == FILE_RETRY) |
761 | 812 | continue; |
762 | 813 | if (temp_status == FILE_ABORT) |
763 | 814 | return_status = temp_status; |
| 815 | if (temp_status == FILE_SKIPALL) |
| 816 | ctx->skip_all = 1; |
| 817 | if (temp_status == FILE_SKIP); |
764 | 818 | break; |
765 | 819 | } |
766 | 820 | |
767 | 821 | while (dest_desc != -1 && mc_close (dest_desc) < 0) { |
| 822 | if ( ctx->skip_all ) |
| 823 | break; |
768 | 824 | temp_status = file_error ( |
769 | 825 | _(" Cannot close target file \"%s\" \n %s "), dst_path); |
770 | 826 | if (temp_status == FILE_RETRY) |
771 | 827 | continue; |
| 828 | if (temp_status == FILE_SKIPALL) |
| 829 | ctx->skip_all = 1; |
| 830 | if (temp_status == FILE_SKIP); |
772 | 831 | return_status = temp_status; |
773 | 832 | break; |
774 | 833 | } |
… |
… |
copy_file_file (FileOpContext *ctx, cons |
785 | 844 | /* Copy has succeeded */ |
786 | 845 | if (!appending && ctx->preserve_uidgid) { |
787 | 846 | while (mc_chown (dst_path, src_uid, src_gid)) { |
| 847 | if ( ctx->skip_all ) |
| 848 | break; |
788 | 849 | temp_status = file_error ( |
789 | 850 | _(" Cannot chown target file \"%s\" \n %s "), dst_path); |
790 | 851 | if (temp_status == FILE_RETRY) |
791 | 852 | continue; |
792 | | return_status = temp_status; |
| 853 | if (temp_status == FILE_SKIPALL) { |
| 854 | ctx->skip_all = 1; |
| 855 | return_status = FILE_CONT; |
| 856 | } |
| 857 | if (temp_status == FILE_SKIP) |
| 858 | return_status = FILE_CONT; |
793 | 859 | break; |
794 | 860 | } |
795 | 861 | } |
796 | 862 | |
797 | 863 | if (!appending && ctx->preserve) { |
798 | 864 | while (mc_chmod (dst_path, (src_mode & ctx->umask_kill))) { |
| 865 | if ( ctx->skip_all ) |
| 866 | break; |
799 | 867 | temp_status = file_error ( |
800 | 868 | _(" Cannot chmod target file \"%s\" \n %s "), dst_path); |
801 | | if (temp_status != FILE_RETRY) { |
802 | | return_status = temp_status; |
803 | | break; |
| 869 | if (temp_status == FILE_RETRY) |
| 870 | continue; |
| 871 | if (temp_status == FILE_SKIPALL){ |
| 872 | ctx->skip_all = 1; |
| 873 | return_status = FILE_CONT; |
804 | 874 | } |
| 875 | if (temp_status == FILE_SKIP) |
| 876 | return_status = FILE_CONT; |
| 877 | break; |
805 | 878 | } |
806 | 879 | mc_utime (dst_path, &utb); |
807 | 880 | } |
… |
… |
erase_file (FileOpContext *ctx, const ch |
1291 | 1364 | } |
1292 | 1365 | |
1293 | 1366 | while (mc_unlink (s)) { |
| 1367 | if ( ctx->skip_all ) |
| 1368 | break; |
1294 | 1369 | return_status = |
1295 | 1370 | file_error (_(" Cannot delete file \"%s\" \n %s "), s); |
1296 | | if (return_status != FILE_RETRY) |
| 1371 | if (return_status == FILE_ABORT) |
1297 | 1372 | return return_status; |
| 1373 | if (return_status == FILE_RETRY) |
| 1374 | continue; |
| 1375 | if (return_status == FILE_SKIPALL) |
| 1376 | ctx->skip_all = 1; |
| 1377 | if (return_status == FILE_SKIP); |
| 1378 | break; |
1298 | 1379 | } |
1299 | | |
1300 | 1380 | if (progress_count) |
1301 | 1381 | return progress_update_one (ctx, progress_count, progress_bytes, |
1302 | 1382 | buf.st_size, is_toplevel_file); |
1303 | 1383 | else |
1304 | 1384 | return FILE_CONT; |
1305 | 1385 | } |
1306 | | |
| 1386 | /* recursive remove of files |
| 1387 | abort->cancel stack |
| 1388 | skip ->warn every level, gets default |
| 1389 | skipall->remove as much as possible |
| 1390 | */ |
1307 | 1391 | static int |
1308 | 1392 | recursive_erase (FileOpContext *ctx, const char *s, off_t *progress_count, |
1309 | 1393 | double *progress_bytes) |
… |
… |
recursive_erase (FileOpContext *ctx, con |
1322 | 1406 | if (!reading) |
1323 | 1407 | return 1; |
1324 | 1408 | |
1325 | | while ((next = mc_readdir (reading)) && return_status == FILE_CONT) { |
| 1409 | while ((next = mc_readdir (reading)) && !(return_status == FILE_ABORT) ) { |
1326 | 1410 | if (!strcmp (next->d_name, ".")) |
1327 | 1411 | continue; |
1328 | 1412 | if (!strcmp (next->d_name, "..")) |
… |
… |
recursive_erase (FileOpContext *ctx, con |
1334 | 1418 | return 1; |
1335 | 1419 | } |
1336 | 1420 | if (S_ISDIR (buf.st_mode)) |
1337 | | return_status = |
1338 | | (recursive_erase |
1339 | | (ctx, path, progress_count, progress_bytes) |
1340 | | != FILE_CONT); |
| 1421 | return_status = |
| 1422 | recursive_erase(ctx, path, progress_count, progress_bytes); |
1341 | 1423 | else |
1342 | 1424 | return_status = |
1343 | 1425 | erase_file (ctx, path, progress_count, progress_bytes, 0); |
1344 | 1426 | g_free (path); |
1345 | 1427 | } |
1346 | 1428 | mc_closedir (reading); |
1347 | | if (return_status != FILE_CONT) |
| 1429 | if (return_status == FILE_ABORT) |
1348 | 1430 | return return_status; |
1349 | 1431 | if (file_progress_show_deleting (ctx, s) == FILE_ABORT) |
1350 | 1432 | return FILE_ABORT; |
1351 | 1433 | mc_refresh (); |
1352 | 1434 | |
1353 | 1435 | while (my_rmdir (s)) { |
| 1436 | if ( ctx->skip_all ) |
| 1437 | break; |
1354 | 1438 | return_status = |
1355 | 1439 | file_error (_(" Cannot remove directory \"%s\" \n %s "), s); |
1356 | | if (return_status != FILE_RETRY) |
| 1440 | if (return_status == FILE_RETRY) |
| 1441 | continue; |
| 1442 | if (return_status == FILE_ABORT) |
1357 | 1443 | return return_status; |
| 1444 | if (return_status == FILE_SKIPALL) |
| 1445 | ctx->skip_all = 1; |
| 1446 | if (return_status == FILE_SKIP); |
| 1447 | break; |
1358 | 1448 | } |
1359 | 1449 | |
1360 | 1450 | return FILE_CONT; |
… |
… |
real_do_file_error (enum OperationMode m |
2075 | 2165 | |
2076 | 2166 | msg = mode == Foreground ? MSG_ERROR : _(" Background process error "); |
2077 | 2167 | result = |
2078 | | query_dialog (msg, error, D_ERROR, 3, _("&Skip"), _("&Retry"), |
| 2168 | query_dialog (msg, error, D_ERROR, 3, _("&Skip"),("Ski&p All"), _("&Retry"), |
2079 | 2169 | _("&Abort")); |
2080 | 2170 | |
2081 | 2171 | switch (result) { |
… |
… |
real_do_file_error (enum OperationMode m |
2085 | 2175 | |
2086 | 2176 | case 1: |
2087 | 2177 | do_refresh (); |
2088 | | return FILE_RETRY; |
| 2178 | return FILE_SKIPALL; |
2089 | 2179 | |
2090 | 2180 | case 2: |
| 2181 | do_refresh (); |
| 2182 | return FILE_RETRY; |
| 2183 | |
| 2184 | case 3: |
2091 | 2185 | default: |
2092 | 2186 | return FILE_ABORT; |
2093 | 2187 | } |
diff -pru mc-4.6.1-orig/src/fileopctx.c mc-4.6.1/src/fileopctx.c
old
|
new
|
file_op_context_new (FileOperation op) |
51 | 51 | ctx->preserve_uidgid = (geteuid () == 0) ? TRUE : FALSE; |
52 | 52 | ctx->umask_kill = 0777777; |
53 | 53 | ctx->erase_at_end = TRUE; |
54 | | |
| 54 | ctx->skip_all = 0; |
55 | 55 | return ctx; |
56 | 56 | } |
57 | 57 | |
diff -pru mc-4.6.1-orig/src/fileopctx.h mc-4.6.1/src/fileopctx.h
old
|
new
|
typedef struct FileOpContext { |
104 | 104 | |
105 | 105 | /* PID of the child for background operations */ |
106 | 106 | pid_t pid; |
| 107 | |
| 108 | /* toggle if all errors should be ignored */ |
| 109 | int skip_all; |
107 | 110 | |
108 | 111 | /* User interface data goes here */ |
109 | 112 | |
… |
… |
typedef enum { |
121 | 124 | FILE_CONT, |
122 | 125 | FILE_RETRY, |
123 | 126 | FILE_SKIP, |
124 | | FILE_ABORT |
| 127 | FILE_ABORT, |
| 128 | FILE_SKIPALL |
125 | 129 | } FileProgressStatus; |
126 | 130 | |
127 | 131 | typedef enum { |