| File tests/fileops/put_files.c changed (mode: 100644) (index 23736a889..a015c918d) |
| ... |
... |
static char options_prompt_rename(const custom_prompt_t *details); |
| 28 |
28 |
static char options_prompt_rename_rec(const custom_prompt_t *details); |
static char options_prompt_rename_rec(const custom_prompt_t *details); |
| 29 |
29 |
static char options_prompt_overwrite(const custom_prompt_t *details); |
static char options_prompt_overwrite(const custom_prompt_t *details); |
| 30 |
30 |
static char options_prompt_abort(const custom_prompt_t *details); |
static char options_prompt_abort(const custom_prompt_t *details); |
|
31 |
|
static char options_prompt_abort_and_record(const custom_prompt_t *details); |
| 31 |
32 |
static char options_prompt_skip_all(const custom_prompt_t *details); |
static char options_prompt_skip_all(const custom_prompt_t *details); |
| 32 |
33 |
static char options_prompt_merge(const custom_prompt_t *details); |
static char options_prompt_merge(const custom_prompt_t *details); |
| 33 |
34 |
static char options_prompt_merge_no_overwrite(const custom_prompt_t *details); |
static char options_prompt_merge_no_overwrite(const custom_prompt_t *details); |
| |
| ... |
... |
static void parent_overwrite_with_put(int move); |
| 38 |
39 |
static void double_clash_with_put(int move); |
static void double_clash_with_put(int move); |
| 39 |
40 |
|
|
| 40 |
41 |
static fo_prompt_cb rename_cb; |
static fo_prompt_cb rename_cb; |
| 41 |
|
static int options_count; |
|
| 42 |
42 |
static int merge_prompt_count; |
static int merge_prompt_count; |
| 43 |
43 |
static int yes_prompt_count; |
static int yes_prompt_count; |
| 44 |
44 |
static int no_prompt_count; |
static int no_prompt_count; |
|
45 |
|
static char response_options[32]; |
| 45 |
46 |
|
|
| 46 |
47 |
static char *saved_cwd; |
static char *saved_cwd; |
| 47 |
48 |
|
|
| |
| ... |
... |
TEST(show_merge_all_option_if_paths_include_dir) |
| 589 |
590 |
create_file(SANDBOX_PATH "/dir/b"); |
create_file(SANDBOX_PATH "/dir/b"); |
| 590 |
591 |
create_dir(SANDBOX_PATH "/dir/sub"); |
create_dir(SANDBOX_PATH "/dir/sub"); |
| 591 |
592 |
|
|
| 592 |
|
fops_init(&line_prompt, &options_prompt_abort); |
|
|
593 |
|
fops_init(&line_prompt, &options_prompt_abort_and_record); |
| 593 |
594 |
|
|
| 594 |
595 |
make_abs_path(path, sizeof(path), SANDBOX_PATH, "/dir/a", saved_cwd); |
make_abs_path(path, sizeof(path), SANDBOX_PATH, "/dir/a", saved_cwd); |
| 595 |
596 |
assert_success(regs_append('a', path)); |
assert_success(regs_append('a', path)); |
| 596 |
597 |
make_abs_path(path, sizeof(path), SANDBOX_PATH, "/dir/b", saved_cwd); |
make_abs_path(path, sizeof(path), SANDBOX_PATH, "/dir/b", saved_cwd); |
| 597 |
598 |
assert_success(regs_append('a', path)); |
assert_success(regs_append('a', path)); |
| 598 |
599 |
|
|
| 599 |
|
options_count = 0; |
|
|
600 |
|
response_options[0] = '\0'; |
| 600 |
601 |
(void)fops_put(&lwin, -1, 'a', 0, /*deep=*/0); |
(void)fops_put(&lwin, -1, 'a', 0, /*deep=*/0); |
| 601 |
|
assert_int_equal(8, options_count); |
|
|
602 |
|
assert_string_doesnt_contain("M", response_options); |
| 602 |
603 |
|
|
| 603 |
604 |
restore_cwd(saved_cwd); |
restore_cwd(saved_cwd); |
| 604 |
605 |
saved_cwd = save_cwd(); |
saved_cwd = save_cwd(); |
| |
| ... |
... |
TEST(show_merge_all_option_if_paths_include_dir) |
| 606 |
607 |
make_abs_path(path, sizeof(path), SANDBOX_PATH, "/dir/sub", saved_cwd); |
make_abs_path(path, sizeof(path), SANDBOX_PATH, "/dir/sub", saved_cwd); |
| 607 |
608 |
assert_success(regs_append('a', path)); |
assert_success(regs_append('a', path)); |
| 608 |
609 |
|
|
| 609 |
|
options_count = 0; |
|
|
610 |
|
response_options[0] = '\0'; |
| 610 |
611 |
(void)fops_put(&lwin, -1, 'a', 0, /*deep=*/0); |
(void)fops_put(&lwin, -1, 'a', 0, /*deep=*/0); |
| 611 |
|
assert_int_equal(9, options_count); |
|
|
612 |
|
assert_string_contains("M", response_options); |
| 612 |
613 |
|
|
| 613 |
614 |
restore_cwd(saved_cwd); |
restore_cwd(saved_cwd); |
| 614 |
615 |
saved_cwd = save_cwd(); |
saved_cwd = save_cwd(); |
| |
| ... |
... |
TEST(no_merge_options_on_putting_links) |
| 630 |
631 |
create_dir(SANDBOX_PATH "/dir"); |
create_dir(SANDBOX_PATH "/dir"); |
| 631 |
632 |
create_dir(SANDBOX_PATH "/dir/sub"); |
create_dir(SANDBOX_PATH "/dir/sub"); |
| 632 |
633 |
|
|
| 633 |
|
fops_init(&line_prompt, &options_prompt_abort); |
|
|
634 |
|
fops_init(&line_prompt, &options_prompt_abort_and_record); |
| 634 |
635 |
|
|
| 635 |
636 |
make_abs_path(path, sizeof(path), SANDBOX_PATH, "/dir/sub", saved_cwd); |
make_abs_path(path, sizeof(path), SANDBOX_PATH, "/dir/sub", saved_cwd); |
| 636 |
637 |
assert_success(regs_append('a', path)); |
assert_success(regs_append('a', path)); |
| 637 |
638 |
|
|
| 638 |
|
options_count = 0; |
|
|
639 |
|
response_options[0] = '\0'; |
| 639 |
640 |
(void)fops_put_links(&lwin, 'a', 0); |
(void)fops_put_links(&lwin, 'a', 0); |
| 640 |
|
assert_int_equal(7, options_count); |
|
|
641 |
|
assert_string_doesnt_contain("m", response_options); |
|
642 |
|
assert_string_doesnt_contain("M", response_options); |
| 641 |
643 |
|
|
| 642 |
644 |
restore_cwd(saved_cwd); |
restore_cwd(saved_cwd); |
| 643 |
645 |
saved_cwd = save_cwd(); |
saved_cwd = save_cwd(); |
| |
| ... |
... |
options_prompt_overwrite(const custom_prompt_t *details) |
| 841 |
843 |
|
|
| 842 |
844 |
static char |
static char |
| 843 |
845 |
options_prompt_abort(const custom_prompt_t *details) |
options_prompt_abort(const custom_prompt_t *details) |
|
846 |
|
{ |
|
847 |
|
return '\x03'; |
|
848 |
|
} |
|
849 |
|
|
|
850 |
|
static char |
|
851 |
|
options_prompt_abort_and_record(const custom_prompt_t *details) |
| 844 |
852 |
{ |
{ |
| 845 |
853 |
const response_variant *variants = details->variants; |
const response_variant *variants = details->variants; |
| 846 |
854 |
|
|
| 847 |
|
options_count = 0; |
|
|
855 |
|
int options_count = 0; |
| 848 |
856 |
while(variants->key != '\0') |
while(variants->key != '\0') |
| 849 |
857 |
{ |
{ |
| 850 |
|
++options_count; |
|
| 851 |
|
++variants; |
|
|
858 |
|
if(options_count + 1 == sizeof(response_options)) |
|
859 |
|
{ |
|
860 |
|
assert_fail("Can't fit all prompt options!"); |
|
861 |
|
break; |
|
862 |
|
} |
|
863 |
|
|
|
864 |
|
response_options[options_count++] = (variants++)->key; |
| 852 |
865 |
} |
} |
| 853 |
866 |
|
|
|
867 |
|
response_options[options_count] = '\0'; |
|
868 |
|
|
| 854 |
869 |
return '\x03'; |
return '\x03'; |
| 855 |
870 |
} |
} |
| 856 |
871 |
|
|