R Under development (unstable) (2025-02-23 r87804 ucrt) -- "Unsuffered Consequences" Copyright (C) 2025 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library("R.utils") Loading required package: R.oo Loading required package: R.methodsS3 R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help. R.oo v1.27.0 (2024-11-01 18:00:02 UTC) successfully loaded. See ?R.oo for help. Attaching package: 'R.oo' The following object is masked from 'package:R.methodsS3': throw The following objects are masked from 'package:methods': getClasses, getMethods The following objects are masked from 'package:base': attach, detach, load, save R.utils v2.13.0 successfully loaded. See ?R.utils for help. Attaching package: 'R.utils' The following object is masked from 'package:utils': timestamp The following objects are masked from 'package:base': cat, commandArgs, getOption, isOpen, nullfile, parse, use, warnings > > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > # Read all HTML files in the base package > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > path <- system.file(package="base") > files <- list.files(path, recursive=TRUE, full.names=TRUE) > files <- files[sapply(files, FUN=isFile)] > nfiles <- length(files) > > cat(sprintf("Reading %d files in %s:\n", nfiles, path)) Reading 24 files in D:/RCompile/recent/R/library/base: > > # Create a status bar with four labels > sb <- TextStatusBar("File: %-*s [%3.0f%% %7.0f bytes %-8s]", + hfill=1, file="", progress=0, nbytes=0L, time="") > > nbytes <- 0L > for (kk in seq_len(nfiles)) { + file <- files[kk] + + # Update the status bar + if (sb) { + setLabel(sb, "progress", 100*kk/nfiles) + if (kk %% 10 == 1 || kk == nfiles) + setLabel(sb, "file", substr(basename(file), 1, 44)) + + size <- file.info(file)$size + # popMessage() calls update() too + popMessage(sb, sprintf("Processing %s (%.2fkB)", + basename(file), size/1024)) + flush(sb) + } + + # Read the file + bfr <- readBin(file, what="raw", n=size) + nbytes <- nbytes + size + + # Emulate a slow process + if (interactive()) Sys.sleep(rexp(1, rate=60)) + + # Update the status bar + if (sb) { + setLabel(sb, "nbytes", nbytes) + setLabel(sb, "time", format(Sys.time(), "%H:%M:%S")) + update(sb) + } + } Processing CITATION (0.63kB) File: CITATION [ 4% 0 bytes ]File: CITATION [ 4% 643 bytes 21:21:49] Processing DESCRIPTION (0.39kB) File: CITATION [ 8% 643 bytes 21:21:49]File: CITATION [ 8% 1041 bytes 21:21:49] Processing INDEX (24.78kB) File: CITATION [ 12% 1041 bytes 21:21:49]File: CITATION [ 12% 26415 bytes 21:21:49] Processing Rd.rds (22.15kB) File: CITATION [ 17% 26415 bytes 21:21:49]File: CITATION [ 17% 49095 bytes 21:21:49] Processing demo.rds (0.25kB) File: CITATION [ 21% 49095 bytes 21:21:49]File: CITATION [ 21% 49347 bytes 21:21:49] Processing features.rds (0.12kB) File: CITATION [ 25% 49347 bytes 21:21:49]File: CITATION [ 25% 49469 bytes 21:21:49] Processing hsearch.rds (22.96kB) File: CITATION [ 29% 49469 bytes 21:21:49]File: CITATION [ 29% 72981 bytes 21:21:49] Processing links.rds (13.29kB) File: CITATION [ 33% 72981 bytes 21:21:49]File: CITATION [ 33% 86593 bytes 21:21:49] Processing package.rds (0.56kB) File: CITATION [ 38% 86593 bytes 21:21:49]File: CITATION [ 38% 87163 bytes 21:21:49] Processing Rprofile (7.25kB) File: CITATION [ 42% 87163 bytes 21:21:49]File: CITATION [ 42% 94589 bytes 21:21:49] Processing base (5.32kB) File: base [ 46% 94589 bytes 21:21:49]File: base [ 46% 100038 bytes 21:21:49] Processing base.rdb (1070.91kB) File: base [ 50% 100038 bytes 21:21:49]File: base [ 50% 1196646 bytes 21:21:49] Processing base.rdx (13.85kB) File: base [ 54% 1196646 bytes 21:21:49]File: base [ 54% 1210829 bytes 21:21:49] Processing error.catching.R (3.29kB) File: base [ 58% 1210829 bytes 21:21:49]File: base [ 58% 1214196 bytes 21:21:49] Processing is.things.R (4.69kB) File: base [ 62% 1214196 bytes 21:21:49]File: base [ 62% 1218994 bytes 21:21:49] Processing recursion.R (2.07kB) File: base [ 67% 1218994 bytes 21:21:49]File: base [ 67% 1221109 bytes 21:21:49] Processing scoping.R (1.52kB) File: base [ 71% 1221109 bytes 21:21:49]File: base [ 71% 1222669 bytes 21:21:49] Processing AnIndex (36.68kB) File: base [ 75% 1222669 bytes 21:21:49]File: base [ 75% 1260228 bytes 21:21:49] Processing aliases.rds (12.42kB) File: base [ 79% 1260228 bytes 21:21:49]File: base [ 79% 1272950 bytes 21:21:49] Processing base.rdb (2468.63kB) File: base [ 83% 1272950 bytes 21:21:49]File: base [ 83% 3800828 bytes 21:21:49] Processing base.rdx (9.15kB) File: base.rdx [ 88% 3800828 bytes 21:21:49]File: base.rdx [ 88% 3810196 bytes 21:21:49] Processing paths.rds (3.10kB) File: base.rdx [ 92% 3810196 bytes 21:21:49]File: base.rdx [ 92% 3813374 bytes 21:21:49] Processing 00Index.html (151.35kB) File: base.rdx [ 96% 3813374 bytes 21:21:49]File: base.rdx [ 96% 3968352 bytes 21:21:49] Processing R.css (1.80kB) File: R.css [100% 3968352 bytes 21:21:49]File: R.css [100% 3970196 bytes 21:21:49]> setLabel(sb, "file", "") > update(sb) File: [100% 3970196 bytes 21:21:49]> cat("\n") > > ## Odds and ends > print(getLabel(sb, "progress")) [1] 100 > print(newline(sb)) NULL > updateLabels(sb) File: [100% 3970196 bytes 21:21:49]> > > proc.time() user system elapsed 0.23 0.04 0.28