Changeset 4377
- Timestamp:
- 09/20/06 17:59:35 (2 years ago)
- Files:
-
- wire/trunk/wire/commands.c (modified) (10 diffs)
- wire/trunk/wire/files.c (modified) (1 diff)
- wire/trunk/wire/files.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
wire/trunk/wire/commands.c
r4376 r4377 619 619 620 620 static void wr_cmd_comment(wi_array_t *arguments) { 621 wi_array_t *paths; 621 622 wi_string_t *path, *comment; 622 623 uint32_t i, count; … … 625 626 626 627 if(count == 1) { 627 path = wr_files_full_path(WI_ARRAY(arguments, 0)); 628 paths = wr_files_full_paths(arguments); 629 count = wi_array_count(paths); 628 630 comment = WI_STR(""); 629 631 630 wr_send_command(WI_STR("COMMENT %#@%c%#@"), 631 path, WR_FIELD_SEPARATOR, 632 comment); 633 } else { 634 comment = wi_array_last_data(arguments); 635 636 for(i = 0; i < count - 1; i++) { 637 path = wr_files_full_path(WI_ARRAY(arguments, i)); 632 for(i = 0; i < count; i++) { 633 path = WI_ARRAY(paths, i); 638 634 639 635 wr_send_command(WI_STR("COMMENT %#@%c%#@"), … … 641 637 comment); 642 638 } 639 } else { 640 paths = wr_files_full_paths(wi_array_subarray_with_range(arguments, wi_make_range(0, wi_array_count(arguments) - 1))); 641 count = wi_array_count(paths); 642 comment = wi_array_last_data(arguments); 643 644 for(i = 0; i < count; i++) { 645 path = WI_ARRAY(paths, i); 646 647 wr_send_command(WI_STR("COMMENT %#@%c%#@"), 648 path, WR_FIELD_SEPARATOR, 649 comment); 650 } 643 651 } 644 652 } … … 671 679 672 680 static void wr_cmd_get(wi_array_t *arguments) { 681 wi_array_t *paths; 673 682 uint32_t i, count; 674 683 675 count = wi_array_count(arguments); 684 paths = wr_files_full_paths(arguments); 685 count = wi_array_count(paths); 676 686 677 687 for(i = 0; i < count; i++) 678 wr_transfer_download( wr_files_full_path(WI_ARRAY(arguments, i)));688 wr_transfer_download(WI_ARRAY(paths, i)); 679 689 680 690 wr_draw_transfers(true); … … 935 945 936 946 static void wr_cmd_mkdir(wi_array_t *arguments) { 947 wi_array_t *paths; 937 948 uint32_t i, count; 938 949 939 count = wi_array_count(arguments); 940 950 paths = wr_files_full_paths(arguments); 951 count = wi_array_count(paths); 952 941 953 for(i = 0; i < count; i++) 942 wr_send_command(WI_STR("FOLDER %#@"), wr_files_full_path(WI_ARRAY(arguments, i)));954 wr_send_command(WI_STR("FOLDER %#@"), WI_ARRAY(paths, i)); 943 955 } 944 956 … … 989 1001 990 1002 static void wr_cmd_mv(wi_array_t *arguments) { 1003 wi_array_t *paths; 991 1004 wi_string_t *frompath, *topath; 1005 wi_boolean_t directory; 992 1006 uint32_t i, count; 993 1007 994 count = wi_array_count(arguments); 995 996 if(count == 2) { 997 frompath = wr_files_full_path(WI_ARRAY(arguments, 0)); 998 topath = wr_files_full_path(WI_ARRAY(arguments, 1)); 999 1000 wr_send_command(WI_STR("MOVE %#@%c%#@"), 1001 frompath, WR_FIELD_SEPARATOR, 1002 topath); 1008 if(wi_array_count(arguments) == 2) { 1009 frompath = WI_ARRAY(arguments, 0); 1010 topath = WI_ARRAY(arguments, 1); 1011 directory = (wi_string_has_suffix(topath, WI_STR("/")) || 1012 wi_is_equal(topath, WI_STR(".")) || 1013 wi_is_equal(topath, WI_STR(".."))); 1014 frompath = wr_files_full_path(frompath); 1015 topath = wr_files_full_path(topath); 1016 1017 if(directory) { 1018 wr_send_command(WI_STR("MOVE %#@%c%#@/%#@"), 1019 frompath, WR_FIELD_SEPARATOR, 1020 topath, wi_string_last_path_component(frompath)); 1021 } else { 1022 wr_send_command(WI_STR("MOVE %#@%c%#@"), 1023 frompath, WR_FIELD_SEPARATOR, 1024 topath); 1025 } 1003 1026 } else { 1004 topath = wr_files_full_path(wi_array_last_data(arguments)); 1027 paths = wr_files_full_paths(arguments); 1028 count = wi_array_count(paths); 1029 topath = wi_array_last_data(paths); 1005 1030 1006 1031 for(i = 0; i < count - 1; i++) { 1007 frompath = wr_files_full_path(WI_ARRAY(arguments, i));1032 frompath = WI_ARRAY(paths, i); 1008 1033 1009 1034 wr_send_command(WI_STR("MOVE %#@%c%#@/%#@"), … … 1236 1261 1237 1262 static void wr_cmd_rm(wi_array_t *arguments) { 1263 wi_array_t *paths; 1238 1264 uint32_t i, count; 1239 1265 1240 count = wi_array_count(arguments); 1266 paths = wr_files_full_paths(arguments); 1267 count = wi_array_count(paths); 1241 1268 1242 1269 for(i = 0; i < count; i++) 1243 wr_send_command(WI_STR("DELETE %#@"), wr_files_full_path(WI_ARRAY(arguments, i)));1270 wr_send_command(WI_STR("DELETE %#@"), WI_ARRAY(paths, i)); 1244 1271 } 1245 1272 … … 1378 1405 1379 1406 static void wr_cmd_stat(wi_array_t *arguments) { 1407 wi_array_t *paths; 1380 1408 uint32_t i, count; 1381 1409 1382 1410 wr_stat_state = WR_STAT_FILE; 1383 1411 1384 count = wi_array_count(arguments); 1412 paths = wr_files_full_paths(arguments); 1413 count = wi_array_count(paths); 1385 1414 1386 1415 for(i = 0; i < count; i++) 1387 wr_send_command(WI_STR("STAT %#@"), wr_files_full_path(WI_ARRAY(arguments, i)));1416 wr_send_command(WI_STR("STAT %#@"), WI_ARRAY(paths, i)); 1388 1417 } 1389 1418 … … 1487 1516 1488 1517 static void wr_cmd_type(wi_array_t *arguments) { 1518 wi_array_t *paths; 1489 1519 wi_string_t *path, *string; 1490 1520 wr_file_type_t type; … … 1505 1535 } 1506 1536 1507 count = wi_array_count(arguments); 1508 1509 for(i = 0; i < count - 1; i++) { 1510 path = wr_files_full_path(WI_ARRAY(arguments, i)); 1537 paths = wr_files_full_paths(wi_array_subarray_with_range(arguments, wi_make_range(0, wi_array_count(arguments) - 1))); 1538 count = wi_array_count(paths); 1539 1540 for(i = 0; i < count; i++) { 1541 path = WI_ARRAY(paths, i); 1511 1542 1512 1543 wr_send_command(WI_STR("TYPE %#@%c%u"), wire/trunk/wire/files.c
r3891 r4377 146 146 147 147 148 wi_array_t * wr_files_full_paths(wi_array_t *paths) { 149 wi_array_t *fullpaths; 150 uint32_t i, count; 151 152 count = wi_array_count(paths); 153 fullpaths = wi_array_init_with_capacity(wi_array_alloc(), count); 154 155 for(i = 0; i < count; i++) 156 wi_array_add_data(fullpaths, wr_files_full_path(WI_ARRAY(paths, i))); 157 158 return wi_autorelease(fullpaths); 159 } 160 161 162 148 163 wi_string_t * wr_files_string_for_size(wi_file_offset_t size) { 149 164 double kb, mb, gb, tb, pb; wire/trunk/wire/files.h
r3566 r4377 74 74 75 75 wi_string_t * wr_files_full_path(wi_string_t *); 76 wi_array_t * wr_files_full_paths(wi_array_t *); 76 77 wi_string_t * wr_files_string_for_size(wi_file_offset_t); 77 78 wi_string_t * wr_files_string_for_count(unsigned int);
