Changeset 0ce9eb8 in mainline for uspace/app
- Timestamp:
- 2026-02-10T12:52:07Z (5 weeks ago)
- Branches:
- master
- Children:
- 857fba8
- Parents:
- 26a9388
- git-author:
- Jiri Svoboda <jiri@…> (2026-02-10 18:51:59)
- git-committer:
- Jiri Svoboda <jiri@…> (2026-02-10 12:52:07)
- Location:
- uspace/app
- Files:
-
- 4 added
- 8 edited
-
copy/copy.c (modified) (5 diffs)
-
nav/copy.c (modified) (2 diffs)
-
nav/dlg/existsdlg.c (added)
-
nav/dlg/existsdlg.h (added)
-
nav/dlg/ioerrdlg.c (modified) (7 diffs)
-
nav/meson.build (modified) (4 diffs)
-
nav/nav.c (modified) (5 diffs)
-
nav/nav.h (modified) (2 diffs)
-
nav/test/dlg/existsdlg.c (added)
-
nav/test/main.c (modified) (2 diffs)
-
nav/types/dlg/existsdlg.h (added)
-
nav/types/nav.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/copy/copy.c
r26a9388 r0ce9eb8 1 1 /* 2 * Copyright (c) 202 5Jiri Svoboda2 * Copyright (c) 2026 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 49 49 static void copy_progress(void *, fmgt_progress_t *); 50 50 static fmgt_error_action_t copy_io_error_query(void *, fmgt_io_error_t *); 51 static fmgt_exists_action_t copy_exists_query(void *, fmgt_exists_t *); 51 52 52 53 static bool prog_upd = false; … … 59 60 .abort_query = copy_abort_query, 60 61 .io_error_query = copy_io_error_query, 62 .exists_query = copy_exists_query, 61 63 .progress = copy_progress, 62 64 }; … … 188 190 if (ev->key == KC_C) 189 191 return fmgt_er_abort; 192 } 193 } 194 } 195 } 196 197 /** Called by fmgt to let user choose destination exists recovery action. 198 * 199 * @param arg Argument (not used) 200 * @param err I/O error report 201 * @return Error recovery action. 202 */ 203 static fmgt_exists_action_t copy_exists_query(void *arg, fmgt_exists_t *exists) 204 { 205 cons_event_t event; 206 kbd_event_t *ev; 207 errno_t rc; 208 209 (void)arg; 210 211 if (nonint) 212 return fmgt_exr_abort; 213 214 if (prog_upd) 215 putchar('\n'); 216 217 fprintf(stderr, "File %s exists.\n", exists->fname); 218 fprintf(stderr, "[O]verwrite, [S]kip or [A]bort?\n"); 219 220 if (con == NULL) 221 return fmgt_exr_abort; 222 223 while (true) { 224 rc = console_get_event(con, &event); 225 if (rc != EOK) 226 return fmgt_exr_abort; 227 228 if (event.type == CEV_KEY && event.ev.key.type == KEY_PRESS) { 229 ev = &event.ev.key; 230 if ((ev->mods & KM_ALT) == 0 && 231 (ev->mods & KM_CTRL) == 0) { 232 if (ev->c == 'o' || ev->c == 'O') 233 return fmgt_exr_overwrite; 234 if (ev->c == 's' || ev->c == 'S') 235 return fmgt_exr_skip; 236 if (ev->c == 'a' || ev->c == 'A') 237 return fmgt_exr_abort; 238 } 239 } 240 241 if (event.type == CEV_KEY && event.ev.key.type == KEY_PRESS) { 242 ev = &event.ev.key; 243 if ((ev->mods & KM_ALT) == 0 && 244 (ev->mods & KM_SHIFT) == 0 && 245 (ev->mods & KM_CTRL) != 0) { 246 if (ev->key == KC_C) 247 return fmgt_exr_abort; 190 248 } 191 249 } … … 256 314 putchar('\n'); 257 315 if (rc != EOK) { 258 printf("Error c reating file: %s.\n", str_error(rc));316 printf("Error copying file(s): %s.\n", str_error(rc)); 259 317 goto error; 260 318 } -
uspace/app/nav/copy.c
r26a9388 r0ce9eb8 1 1 /* 2 * Copyright (c) 202 5Jiri Svoboda2 * Copyright (c) 2026 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 69 69 .abort_query = copy_abort_query, 70 70 .io_error_query = navigator_io_error_query, 71 .exists_query = navigator_exists_query, 71 72 .progress = copy_progress, 72 73 }; -
uspace/app/nav/dlg/ioerrdlg.c
r26a9388 r0ce9eb8 1 1 /* 2 * Copyright (c) 202 5Jiri Svoboda2 * Copyright (c) 2026 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 272 272 } 273 273 274 /** Destroy promptdialog.275 * 276 * @param dialog Promptdialog or @c NULL274 /** Destroy I/O error dialog. 275 * 276 * @param dialog I/O error dialog or @c NULL 277 277 */ 278 278 void io_err_dlg_destroy(io_err_dlg_t *dialog) … … 285 285 } 286 286 287 /** Set mesagedialog callback.288 * 289 * @param dialog Promptdialog290 * @param cb Promptdialog callbacks287 /** Set I/O error dialog callback. 288 * 289 * @param dialog I/O error dialog 290 * @param cb I/O error dialog callbacks 291 291 * @param arg Callback argument 292 292 */ … … 298 298 } 299 299 300 /** Promptdialog window close handler.300 /** I/O error dialog window close handler. 301 301 * 302 302 * @param window Window … … 313 313 } 314 314 315 /** Promptdialog window keyboard event handler.315 /** I/O error dialog window keyboard event handler. 316 316 * 317 317 * @param window Window … … 344 344 } 345 345 346 /** Prompt dialog OKbutton click handler.346 /** I/O error dialog abort button click handler. 347 347 * 348 348 * @param pbutton Push button … … 358 358 } 359 359 360 /** Prompt dialog cancelbutton click handler.360 /** I/O error dialog retry button click handler. 361 361 * 362 362 * @param pbutton Push button -
uspace/app/nav/meson.build
r26a9388 r0ce9eb8 1 1 # 2 # Copyright (c) 202 5Jiri Svoboda2 # Copyright (c) 2026 Jiri Svoboda 3 3 # All rights reserved. 4 4 # … … 30 30 src = files( 31 31 'dlg/copydlg.c', 32 'dlg/existsdlg.c', 32 33 'dlg/ioerrdlg.c', 33 34 'dlg/newfiledlg.c', … … 45 46 test_src = files( 46 47 'dlg/copydlg.c', 48 'dlg/existsdlg.c', 47 49 'dlg/ioerrdlg.c', 48 50 'dlg/newfiledlg.c', … … 56 58 'verify.c', 57 59 'test/dlg/copydlg.c', 60 'test/dlg/existsdlg.c', 58 61 'test/dlg/ioerrdlg.c', 59 62 'test/dlg/newfiledlg.c', -
uspace/app/nav/nav.c
r26a9388 r0ce9eb8 1 1 /* 2 * Copyright (c) 202 5Jiri Svoboda2 * Copyright (c) 2026 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 49 49 #include <ui/window.h> 50 50 #include "copy.h" 51 #include "dlg/existsdlg.h" 51 52 #include "dlg/ioerrdlg.h" 52 53 #include "menu.h" … … 106 107 .bretry = navigator_io_err_retry, 107 108 .close = navigator_io_err_close 109 }; 110 111 static void navigator_exists_overwrite(exists_dlg_t *, void *); 112 static void navigator_exists_skip(exists_dlg_t *, void *); 113 static void navigator_exists_abort(exists_dlg_t *, void *); 114 static void navigator_exists_close(exists_dlg_t *, void *); 115 116 static exists_dlg_cb_t navigator_exists_dlg_cb = { 117 .boverwrite = navigator_exists_overwrite, 118 .bskip = navigator_exists_skip, 119 .babort = navigator_exists_abort, 120 .close = navigator_exists_close 108 121 }; 109 122 … … 273 286 navigator->io_err_act_sel = false; 274 287 288 fibril_mutex_initialize(&navigator->exists_act_lock); 289 fibril_condvar_initialize(&navigator->exists_act_cv); 290 navigator->exists_act_sel = false; 291 275 292 *rnavigator = navigator; 276 293 return EOK; … … 857 874 } 858 875 876 /** Called by fmgt to query for file/directory exists recovery action. 877 * 878 * @param arg Argument (navigator_t *) 879 * @param exists File/directory exists report 880 * @return Recovery action to take. 881 */ 882 fmgt_exists_action_t navigator_exists_query(void *arg, fmgt_exists_t *exists) 883 { 884 navigator_t *nav = (navigator_t *)arg; 885 exists_dlg_t *dlg; 886 exists_dlg_params_t params; 887 fmgt_exists_action_t exists_act; 888 char *text1; 889 errno_t rc; 890 int rv; 891 892 exists_dlg_params_init(¶ms); 893 rv = asprintf(&text1, "File %s exists.", exists->fname); 894 if (rv < 0) 895 return fmgt_exr_abort; 896 897 params.text1 = text1; 898 899 ui_lock(nav->ui); 900 rc = exists_dlg_create(nav->ui, ¶ms, &dlg); 901 if (rc != EOK) { 902 ui_unlock(nav->ui); 903 free(text1); 904 return fmgt_exr_abort; 905 } 906 907 exists_dlg_set_cb(dlg, &navigator_exists_dlg_cb, (void *)nav); 908 909 ui_unlock(nav->ui); 910 free(text1); 911 912 fibril_mutex_lock(&nav->exists_act_lock); 913 914 while (!nav->exists_act_sel) { 915 fibril_condvar_wait(&nav->exists_act_cv, 916 &nav->exists_act_lock); 917 } 918 919 exists_act = nav->exists_act; 920 nav->exists_act_sel = false; 921 fibril_mutex_unlock(&nav->exists_act_lock); 922 923 return exists_act; 924 } 925 926 /** File/directory exists dialog overwrite button was pressed. 927 * 928 * @param dlg File/directory exists dialog 929 * @param arg Argument (navigator_t *) 930 */ 931 static void navigator_exists_overwrite(exists_dlg_t *dlg, void *arg) 932 { 933 navigator_t *nav = (navigator_t *)arg; 934 935 exists_dlg_destroy(dlg); 936 937 fibril_mutex_lock(&nav->exists_act_lock); 938 nav->exists_act = fmgt_exr_overwrite; 939 nav->exists_act_sel = true; 940 fibril_condvar_signal(&nav->exists_act_cv); 941 fibril_mutex_unlock(&nav->exists_act_lock); 942 } 943 944 /** File/directory exists dialog skip button was pressed. 945 * 946 * @param dlg File/directory exists dialog 947 * @param arg Argument (navigator_t *) 948 */ 949 static void navigator_exists_skip(exists_dlg_t *dlg, void *arg) 950 { 951 navigator_t *nav = (navigator_t *)arg; 952 953 exists_dlg_destroy(dlg); 954 955 fibril_mutex_lock(&nav->exists_act_lock); 956 nav->exists_act = fmgt_exr_skip; 957 nav->exists_act_sel = true; 958 fibril_condvar_signal(&nav->exists_act_cv); 959 fibril_mutex_unlock(&nav->exists_act_lock); 960 } 961 962 /** File/directory exists dialog abort button was pressed. 963 * 964 * @param dlg File/directory exists dialog 965 * @param arg Argument (navigator_t *) 966 */ 967 static void navigator_exists_abort(exists_dlg_t *dlg, void *arg) 968 { 969 navigator_t *nav = (navigator_t *)arg; 970 971 exists_dlg_destroy(dlg); 972 973 fibril_mutex_lock(&nav->exists_act_lock); 974 nav->exists_act = fmgt_exr_abort; 975 nav->exists_act_sel = true; 976 fibril_condvar_signal(&nav->exists_act_cv); 977 fibril_mutex_unlock(&nav->exists_act_lock); 978 } 979 980 /** File/directory exists dialog closure requested. 981 * 982 * @param dlg File/directory exists dialog 983 * @param arg Argument (navigator_t *) 984 */ 985 static void navigator_exists_close(exists_dlg_t *dlg, void *arg) 986 { 987 navigator_t *nav = (navigator_t *)arg; 988 989 exists_dlg_destroy(dlg); 990 991 fibril_mutex_lock(&nav->exists_act_lock); 992 nav->exists_act = fmgt_exr_abort; 993 nav->exists_act_sel = true; 994 fibril_condvar_signal(&nav->exists_act_cv); 995 fibril_mutex_unlock(&nav->exists_act_lock); 996 } 997 859 998 /** @} 860 999 */ -
uspace/app/nav/nav.h
r26a9388 r0ce9eb8 1 1 /* 2 * Copyright (c) 202 5Jiri Svoboda2 * Copyright (c) 2026 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 55 55 void *); 56 56 extern fmgt_error_action_t navigator_io_error_query(void *, fmgt_io_error_t *); 57 extern fmgt_exists_action_t navigator_exists_query(void *, fmgt_exists_t *); 57 58 58 59 #endif -
uspace/app/nav/test/main.c
r26a9388 r0ce9eb8 1 1 /* 2 * Copyright (c) 202 5Jiri Svoboda2 * Copyright (c) 2026 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 32 32 33 33 PCUT_IMPORT(copydlg); 34 PCUT_IMPORT(existsdlg); 34 35 PCUT_IMPORT(ioerrdlg); 35 36 PCUT_IMPORT(newfiledlg); -
uspace/app/nav/types/nav.h
r26a9388 r0ce9eb8 1 1 /* 2 * Copyright (c) 202 5Jiri Svoboda2 * Copyright (c) 2026 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 75 75 /** Synchronizes access to I/O error recovery action */ 76 76 fibril_mutex_t io_err_act_lock; 77 78 /** @c true if user selected file/dir exists recovery action */ 79 bool exists_act_sel; 80 /** Selected file/directory exists recovery action */ 81 fmgt_exists_action_t exists_act; 82 /** Signalled when user selects file/directory exists recovery action */ 83 fibril_condvar_t exists_act_cv; 84 /** Synchronizes access to file/directory exists recovery action */ 85 fibril_mutex_t exists_act_lock; 77 86 } navigator_t; 78 87
Note:
See TracChangeset
for help on using the changeset viewer.
