Changeset c3db721 in mainline
- Timestamp:
- 2025-10-10T20:35:05Z (2 months ago)
- Branches:
- master
- Children:
- c1383cd
- Parents:
- 0cf3d5f
- Location:
- uspace
- Files:
-
- 8 edited
-
app/nav/nav.c (modified) (2 diffs)
-
app/nav/nav.h (modified) (1 diff)
-
app/nav/newfile.c (modified) (4 diffs)
-
app/nav/types/nav.h (modified) (2 diffs)
-
app/newfile/meson.build (modified) (1 diff)
-
app/newfile/newfile.c (modified) (6 diffs)
-
lib/fmgt/include/types/fmgt.h (modified) (2 diffs)
-
lib/fmgt/src/fmgt.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/nav/nav.c
r0cf3d5f rc3db721 79 79 .activate_req = navigator_panel_activate_req, 80 80 .file_open = navigator_panel_file_open 81 }; 82 83 static void navigator_progress_babort(progress_dlg_t *, void *); 84 static void navigator_progress_close(progress_dlg_t *, void *); 85 86 progress_dlg_cb_t navigator_progress_cb = { 87 .babort = navigator_progress_babort, 88 .close = navigator_progress_close 81 89 }; 82 90 … … 596 604 } 597 605 606 /** Abort button pressed in progress dialog. 607 * 608 * @param dlg Progress dialog 609 * @param arg Argument (navigator_t *) 610 */ 611 static void navigator_progress_babort(progress_dlg_t *dlg, void *arg) 612 { 613 navigator_t *nav = (navigator_t *)arg; 614 615 (void)dlg; 616 nav->abort_op = true; 617 } 618 619 /** Progress dialog closed, 620 * 621 * @param dlg Progress dialog 622 * @param arg Argument (navigator_t *) 623 */ 624 static void navigator_progress_close(progress_dlg_t *dlg, void *arg) 625 { 626 navigator_t *nav = (navigator_t *)arg; 627 628 (void)dlg; 629 nav->abort_op = true; 630 } 631 598 632 /** @} 599 633 */ -
uspace/app/nav/nav.h
r0cf3d5f rc3db721 38 38 39 39 #include <errno.h> 40 #include "types/dlg/progress.h" 40 41 #include "types/nav.h" 41 42 #include "types/panel.h" 43 44 extern progress_dlg_cb_t navigator_progress_cb; 42 45 43 46 extern errno_t navigator_create(const char *, navigator_t **); -
uspace/app/nav/newfile.c
r0cf3d5f rc3db721 64 64 }; 65 65 66 static bool new_file_abort_query(void *); 66 67 static void new_file_progress(void *, fmgt_progress_t *); 67 68 68 69 static fmgt_cb_t new_file_fmgt_cb = { 69 .progress = new_file_progress 70 .abort_query = new_file_abort_query, 71 .progress = new_file_progress, 70 72 }; 71 73 … … 124 126 return; 125 127 error: 128 fmgt_destroy(fmgt); 126 129 ui_lock(nav->ui); 127 130 progress_dlg_destroy(nav->progress_dlg); 131 navigator_refresh_panels(nav); 128 132 ui_msg_dialog_params_init(¶ms); 129 133 params.caption = "Error"; … … 192 196 } 193 197 198 progress_dlg_set_cb(nav->progress_dlg, &navigator_progress_cb, 199 (void *)nav); 200 194 201 rc = navigator_worker_start(nav, new_file_wfunc, (void *)job); 195 202 if (rc != EOK) { … … 231 238 } 232 239 240 /** New file abort query. 241 * 242 * @param arg Argument (navigator_t *) 243 * @return @c true iff abort is requested 244 */ 245 static bool new_file_abort_query(void *arg) 246 { 247 navigator_t *nav = (navigator_t *)arg; 248 249 return nav->abort_op; 250 } 251 233 252 /** New file progress update. 234 253 * -
uspace/app/nav/types/nav.h
r0cf3d5f rc3db721 38 38 39 39 #include <fibril.h> 40 #include <stdbool.h> 40 41 #include <ui/fixed.h> 41 42 #include <ui/ui.h> … … 62 63 /** Worker fibril ID */ 63 64 fid_t worker_fid; 65 /** Abort current file management operation */ 66 bool abort_op; 64 67 } navigator_t; 65 68 -
uspace/app/newfile/meson.build
r0cf3d5f rc3db721 27 27 # 28 28 29 deps = [ ' fmgt' ]29 deps = [ 'console', 'fmgt', 'input' ] 30 30 src = files('newfile.c') -
uspace/app/newfile/newfile.c
r0cf3d5f rc3db721 36 36 #include <errno.h> 37 37 #include <fmgt.h> 38 #include <io/console.h> 39 #include <io/cons_event.h> 40 #include <io/kbd_event.h> 38 41 #include <stdbool.h> 39 42 #include <stdio.h> … … 44 47 #define NAME "newfile" 45 48 49 static bool newfile_abort_query(void *); 46 50 static void newfile_progress(void *, fmgt_progress_t *); 47 51 … … 49 53 static bool quiet = false; 50 54 55 static console_ctrl_t *con; 56 51 57 static fmgt_cb_t newfile_fmgt_cb = { 58 .abort_query = newfile_abort_query, 52 59 .progress = newfile_progress 53 60 }; … … 62 69 printf("\t-q quiet\n"); 63 70 printf("\t-size=<cap> file size (<number>[<kB>|<MB>|...])\n"); 71 } 72 73 /** Called by fmgt to query for user abort. 74 * 75 * @param arg Argument (not used) 76 * @return @c true iff user requested abort 77 */ 78 static bool newfile_abort_query(void *arg) 79 { 80 cons_event_t event; 81 kbd_event_t *ev; 82 errno_t rc; 83 usec_t timeout; 84 85 if (con == NULL) 86 return false; 87 88 timeout = 0; 89 rc = console_get_event_timeout(con, &event, &timeout); 90 if (rc != EOK) 91 return false; 92 93 if (event.type == CEV_KEY && event.ev.key.type == KEY_PRESS) { 94 ev = &event.ev.key; 95 if ((ev->mods & KM_ALT) == 0 && 96 (ev->mods & KM_SHIFT) == 0 && 97 (ev->mods & KM_CTRL) != 0) { 98 if (ev->key == KC_C) 99 return true; 100 } 101 } 102 103 return false; 64 104 } 65 105 … … 93 133 uint64_t nbytes = 0; 94 134 135 con = console_init(stdin, stdout); 136 95 137 i = 1; 96 138 while (i < argc && argv[i][0] == '-') { … … 167 209 168 210 rc = fmgt_new_file(fmgt, fname, nbytes, sparse ? nf_sparse : nf_none); 211 if (prog_upd) 212 printf("\n"); 169 213 if (rc != EOK) { 170 214 printf("Error creating file: %s.\n", str_error(rc)); 171 215 goto error; 172 216 } 173 174 if (prog_upd)175 printf("\n");176 217 177 218 free(fname); -
uspace/lib/fmgt/include/types/fmgt.h
r0cf3d5f rc3db721 40 40 #include <capa.h> 41 41 #include <fibril_synch.h> 42 #include <stdbool.h> 42 43 43 44 /** File management progress update */ … … 53 54 /** File management callbacks */ 54 55 typedef struct { 56 bool (*abort_query)(void *); 55 57 void (*progress)(void *, fmgt_progress_t *); 56 58 } fmgt_cb_t; -
uspace/lib/fmgt/src/fmgt.c
r0cf3d5f rc3db721 221 221 } 222 222 223 /** Query caller whether operation should be aborted. 224 * 225 * @param fmgt File management object 226 * @return @c true iff operation should be aborted 227 */ 228 static bool fmgt_abort_query(fmgt_t *fmgt) 229 { 230 if (fmgt->cb != NULL && fmgt->cb->abort_query!= NULL) 231 return fmgt->cb->abort_query(fmgt->cb_arg); 232 else 233 return false; 234 } 235 223 236 /** Create new file. 224 237 * … … 276 289 277 290 fmgt->curf_procb += nw; 291 292 /* User requested abort? */ 293 if (fmgt_abort_query(fmgt)) { 294 free(buffer); 295 vfs_put(fd); 296 fmgt_final_progress_update(fmgt); 297 return EINTR; 298 } 278 299 } 279 300
Note:
See TracChangeset
for help on using the changeset viewer.
