Changeset 4376

Show
Ignore:
Timestamp:
09/20/06 17:59:33 (2 years ago)
Author:
morris
Message:

Allow multiple paths in all commands that now take single paths

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • wire/trunk/wire/commands.c

    r4375 r4376  
    130130        { "comment", 
    131131          true, "<path> <comment>", 
    132           true, 1, 1, WR_COMPLETER_FILENAME, 
     132          true, 1, -1, WR_COMPLETER_FILENAME, 
    133133          wr_cmd_comment }, 
    134134        { "connect", 
     
    202202        { "mkdir", 
    203203          true, "<path>", 
    204           true, 1, 0, WR_COMPLETER_FILENAME, 
     204          true, 1, -1, WR_COMPLETER_FILENAME, 
    205205          wr_cmd_mkdir }, 
    206206        { "move", 
     
    620620static void wr_cmd_comment(wi_array_t *arguments) { 
    621621        wi_string_t             *path, *comment; 
    622          
    623         path = wr_files_full_path(WI_ARRAY(arguments, 0)); 
    624         comment = wi_array_count(arguments) == 1 ? WI_STR("") : WI_ARRAY(arguments, 1); 
    625  
    626         wr_send_command(WI_STR("COMMENT %#@%c%#@"), 
    627                 path,           WR_FIELD_SEPARATOR, 
    628                 comment); 
     622        uint32_t                i, count; 
     623         
     624        count = wi_array_count(arguments); 
     625         
     626        if(count == 1) { 
     627                path = wr_files_full_path(WI_ARRAY(arguments, 0)); 
     628                comment = WI_STR(""); 
     629 
     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)); 
     638                         
     639                        wr_send_command(WI_STR("COMMENT %#@%c%#@"), 
     640                                path,           WR_FIELD_SEPARATOR, 
     641                                comment); 
     642                } 
     643        } 
    629644} 
    630645 
     
    920935 
    921936static void wr_cmd_mkdir(wi_array_t *arguments) { 
    922         wi_string_t             *path; 
    923          
    924         path = wr_files_full_path(WI_ARRAY(arguments, 0)); 
    925  
    926         wr_send_command(WI_STR("FOLDER %#@"), path); 
     937        uint32_t                i, count; 
     938         
     939        count = wi_array_count(arguments); 
     940         
     941        for(i = 0; i < count; i++) 
     942                wr_send_command(WI_STR("FOLDER %#@"), wr_files_full_path(WI_ARRAY(arguments, i))); 
    927943} 
    928944 
     
    973989 
    974990static void wr_cmd_mv(wi_array_t *arguments) { 
    975         wi_string_t             *from, *to; 
    976          
    977         from    = wr_files_full_path(WI_ARRAY(arguments, 0)); 
    978         to              = wr_files_full_path(WI_ARRAY(arguments, 1)); 
    979  
    980         wr_send_command(WI_STR("MOVE %#@%c%#@"), 
    981                 from,           WR_FIELD_SEPARATOR, 
    982                 to); 
     991        wi_string_t             *frompath, *topath; 
     992        uint32_t                i, count; 
     993         
     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); 
     1003        } else { 
     1004                topath = wr_files_full_path(wi_array_last_data(arguments)); 
     1005                 
     1006                for(i = 0; i < count - 1; i++) { 
     1007                        frompath = wr_files_full_path(WI_ARRAY(arguments, i)); 
     1008 
     1009                        wr_send_command(WI_STR("MOVE %#@%c%#@/%#@"), 
     1010                                frompath,               WR_FIELD_SEPARATOR, 
     1011                                topath, wi_string_last_path_component(frompath)); 
     1012                } 
     1013        } 
    9831014} 
    9841015 
     
    12051236 
    12061237static void wr_cmd_rm(wi_array_t *arguments) { 
    1207         wi_string_t             *path; 
    1208          
    1209         path = wr_files_full_path(WI_ARRAY(arguments, 0)); 
    1210  
    1211         wr_send_command(WI_STR("DELETE %#@"), path); 
     1238        uint32_t                i, count; 
     1239         
     1240        count = wi_array_count(arguments); 
     1241         
     1242        for(i = 0; i < count; i++) 
     1243                wr_send_command(WI_STR("DELETE %#@"), wr_files_full_path(WI_ARRAY(arguments, i))); 
    12121244} 
    12131245 
     
    13531385         
    13541386        for(i = 0; i < count; i++) 
    1355                 wr_send_command(WI_STR("STAT %@"), wr_files_full_path(WI_ARRAY(arguments, i))); 
     1387                wr_send_command(WI_STR("STAT %#@"), wr_files_full_path(WI_ARRAY(arguments, i))); 
    13561388} 
    13571389 
     
    14571489        wi_string_t                     *path, *string; 
    14581490        wr_file_type_t          type; 
    1459  
    1460         path = wr_files_full_path(WI_ARRAY(arguments, 0)); 
    1461         string = WI_ARRAY(arguments, 1); 
     1491        uint32_t                        i, count; 
     1492 
     1493        string = wi_array_last_data(arguments); 
    14621494 
    14631495        if(wi_is_equal(string, WI_STR("folder"))) 
     
    14721504                return; 
    14731505        } 
    1474  
    1475         wr_send_command(WI_STR("TYPE %#@%c%u"), 
    1476                 path,           WR_FIELD_SEPARATOR, 
    1477                 type); 
     1506         
     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)); 
     1511                 
     1512                wr_send_command(WI_STR("TYPE %#@%c%u"), 
     1513                        path,           WR_FIELD_SEPARATOR, 
     1514                        type); 
     1515        } 
    14781516} 
    14791517