Changeset 1ec732a in mainline for uspace/lib/fmgt/src


Ignore:
Timestamp:
2025-11-28T20:40:11Z (3 weeks ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
144fafd
Parents:
3a4c6d9
Message:

Verify file - navigator operation and command-line utility.

Location:
uspace/lib/fmgt/src
Files:
3 added
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/fmgt/src/fmgt.c

    r3a4c6d9 r1ec732a  
    104104}
    105105
     106/** Initialize progress counters at beginning of operation.
     107 *
     108 * @param fmgt File management object
     109 */
     110void fmgt_progress_init(fmgt_t *fmgt)
     111{
     112        fmgt->total_procf = 0;
     113        fmgt->total_procb = 0;
     114
     115        fmgt->curf_procb = 0;
     116        fmgt->curf_totalb = 0;
     117        fmgt->curf_progr = false;
     118}
     119
     120/** Initialize progress counters at beginning of processing a file.
     121 *
     122 * @param fmgt File management object
     123 * @param fname File name
     124 */
     125void fmgt_progress_init_file(fmgt_t *fmgt, const char *fname)
     126{
     127        vfs_stat_t stat;
     128        errno_t rc;
     129
     130        fmgt->curf_procb = 0;
     131        fmgt->curf_totalb = 0;
     132
     133        rc = vfs_stat_path(fname, &stat);
     134        if (rc == EOK)
     135                fmgt->curf_totalb = stat.size;
     136}
     137
     138/** Increase count of processed bytes.
     139 *
     140 * @param fmgt File management object
     141 * @param nbytes Number of newly processed bytes
     142 */
     143void fmgt_progress_incr_bytes(fmgt_t *fmgt, uint64_t nbytes)
     144{
     145        fmgt->curf_procb += nbytes;
     146        fmgt->total_procb += nbytes;
     147}
     148
     149/** Increase count of processed files.
     150 *
     151 * @parma fmgt File management object
     152 */
     153void fmgt_progress_incr_files(fmgt_t *fmgt)
     154{
     155        ++fmgt->total_procf;
     156}
     157
    106158/** Get progress update report.
    107159 *
     
    124176        snprintf(progress->curf_percent, sizeof(progress->curf_percent), "%u%%",
    125177            percent);
     178        snprintf(progress->total_procf, sizeof(progress->total_procf), "%u",
     179            fmgt->total_procf);
     180        capa_blocks_format_buf(fmgt->total_procb, 1, progress->total_procb,
     181            sizeof(progress->total_procb));
    126182}
    127183
  • uspace/lib/fmgt/src/newfile.c

    r3a4c6d9 r1ec732a  
    3030 * @{
    3131 */
    32 /** @file File management library - creating new files.
     32/** @file Create new files.
    3333 */
    3434
     
    109109        }
    110110
    111         fmgt->curf_procb = 0;
    112         fmgt->curf_totalb = fsize;
    113         fmgt->curf_progr = false;
    114         fmgt_timer_start(fmgt);
    115 
     111        /* Clear statistics. */
     112        fmgt_progress_init(fmgt);
    116113        fmgt_initial_progress_update(fmgt);
    117114
     
    149146                }
    150147
    151                 fmgt->curf_procb += nw;
     148                fmgt_progress_incr_bytes(fmgt, nw);
    152149
    153150                /* User requested abort? */
Note: See TracChangeset for help on using the changeset viewer.