/* changes attributes of files in the view */ static void files_attrib(FileView *view, DWORD add, DWORD sub, int recurse_dirs) { int i; ui_cancellation_reset(); i = 0; while(i < view->list_rows && !view->dir_entry[i].selected) i++; if(i == view->list_rows) { char buf[COMMAND_GROUP_INFO_LEN]; snprintf(buf, sizeof(buf), "chmod in %s: %s", replace_home_part(view->curr_dir), view->dir_entry[view->list_pos].name); cmd_group_begin(buf); attrib_file_in_list(view, view->list_pos, add, sub, recurse_dirs); } else { char buf[COMMAND_GROUP_INFO_LEN]; size_t len; int j = i; len = snprintf(buf, sizeof(buf), "chmod in %s: ", replace_home_part(view->curr_dir)); while(i < view->list_rows && len < sizeof(buf)) { if(view->dir_entry[i].selected) { if(len >= 2 && buf[len - 2] != ':') { strncat(buf + len, ", ", sizeof(buf) - len - 1); len += strlen(buf + len); } strncat(buf + len, view->dir_entry[i].name, sizeof(buf) - len - 1); len += strlen(buf + len); } i++; } cmd_group_begin(buf); while(j < view->list_rows && !ui_cancellation_requested()) { if(view->dir_entry[j].selected) { attrib_file_in_list(view, j, add, sub, recurse_dirs); } j++; } } cmd_group_end(); }
/* Changes attributes of files in the view. */ static void files_attrib(FileView *view, DWORD add, DWORD sub, int recurse_dirs) { char undo_msg[COMMAND_GROUP_INFO_LEN]; dir_entry_t *entry; size_t len; snprintf(undo_msg, sizeof(undo_msg), "chmod in %s: ", replace_home_part(flist_get_dir(view))); len = strlen(undo_msg); ui_cancellation_reset(); entry = NULL; while(iter_selection_or_current(view, &entry) && !ui_cancellation_requested()) { if(len >= 2U && undo_msg[len - 2U] != ':') { strncat(undo_msg + len, ", ", sizeof(undo_msg) - len - 1); len += strlen(undo_msg + len); } strncat(undo_msg + len, entry->name, sizeof(undo_msg) - len - 1); len += strlen(undo_msg + len); } cmd_group_begin(undo_msg); entry = NULL; while(iter_selection_or_current(view, &entry) && !ui_cancellation_requested()) { attrib_file_in_list(view, entry_to_pos(view, entry), add, sub, recurse_dirs); } cmd_group_end(); }