Changeset c3db721 in mainline for uspace/app/newfile
- Timestamp:
- 2025-10-10T20:35:05Z (5 months ago)
- Branches:
- master
- Children:
- c1383cd
- Parents:
- 0cf3d5f
- Location:
- uspace/app/newfile
- Files:
-
- 2 edited
-
meson.build (modified) (1 diff)
-
newfile.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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);
Note:
See TracChangeset
for help on using the changeset viewer.
