Changeset bb4d0b5 in mainline for uspace/app/newfile
- Timestamp:
- 2025-10-18T19:29:40Z (3 months ago)
- Branches:
- master
- Children:
- 3e41cc4
- Parents:
- 856a7b49
- File:
-
- 1 edited
-
uspace/app/newfile/newfile.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/newfile/newfile.c
r856a7b49 rbb4d0b5 49 49 static bool newfile_abort_query(void *); 50 50 static void newfile_progress(void *, fmgt_progress_t *); 51 static fmgt_error_action_t newfile_io_error_query(void *, fmgt_io_error_t *); 51 52 52 53 static bool prog_upd = false; 54 static bool nonint = false; 53 55 static bool quiet = false; 54 56 … … 57 59 static fmgt_cb_t newfile_fmgt_cb = { 58 60 .abort_query = newfile_abort_query, 59 .progress = newfile_progress 61 .io_error_query = newfile_io_error_query, 62 .progress = newfile_progress, 60 63 }; 61 64 … … 121 124 } 122 125 126 /** Called by fmgt to let user choose I/O error recovery action. 127 * 128 * @param arg Argument (not used) 129 * @param err I/O error report 130 * @return Error recovery action. 131 */ 132 static fmgt_error_action_t newfile_io_error_query(void *arg, 133 fmgt_io_error_t *err) 134 { 135 cons_event_t event; 136 kbd_event_t *ev; 137 errno_t rc; 138 139 (void)arg; 140 141 if (nonint) 142 return fmgt_er_abort; 143 144 if (prog_upd) 145 putchar('\n'); 146 147 fprintf(stderr, "I/O error %s file '%s' (%s).\n", 148 err->optype == fmgt_io_write ? "writing" : "reading", 149 err->fname, str_error(err->rc)); 150 fprintf(stderr, "[A]bort or [R]etry?\n"); 151 152 if (con == NULL) 153 return fmgt_er_abort; 154 155 while (true) { 156 rc = console_get_event(con, &event); 157 if (rc != EOK) 158 return fmgt_er_abort; 159 160 if (event.type == CEV_KEY && event.ev.key.type == KEY_PRESS) { 161 ev = &event.ev.key; 162 if ((ev->mods & KM_ALT) == 0 && 163 (ev->mods & KM_CTRL) == 0) { 164 if (ev->c == 'r' || ev->c == 'R') 165 return fmgt_er_retry; 166 if (ev->c == 'a' || ev->c == 'A') 167 return fmgt_er_abort; 168 } 169 } 170 171 if (event.type == CEV_KEY && event.ev.key.type == KEY_PRESS) { 172 ev = &event.ev.key; 173 if ((ev->mods & KM_ALT) == 0 && 174 (ev->mods & KM_SHIFT) == 0 && 175 (ev->mods & KM_CTRL) != 0) { 176 if (ev->key == KC_C) 177 return fmgt_er_abort; 178 } 179 } 180 } 181 } 182 123 183 int main(int argc, char *argv[]) 124 184 { … … 126 186 errno_t rc; 127 187 int i; 128 bool nonint = false;129 188 bool sparse = false; 130 189 char *fsize = NULL; … … 210 269 rc = fmgt_new_file(fmgt, fname, nbytes, sparse ? nf_sparse : nf_none); 211 270 if (prog_upd) 212 p rintf("\n");271 putchar('\n'); 213 272 if (rc != EOK) { 214 273 printf("Error creating file: %s.\n", str_error(rc));
Note:
See TracChangeset
for help on using the changeset viewer.
