R Under development (unstable) (2023-11-16 r85542 ucrt) -- "Unsuffered Consequences" Copyright (C) 2023 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.25.0 (2022-06-12 02:20: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.12.3 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, 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 08:48:06] Processing DESCRIPTION (0.39kB) File: CITATION [ 8% 643 bytes 08:48:06]File: CITATION [ 8% 1041 bytes 08:48:06] Processing INDEX (24.76kB) File: CITATION [ 12% 1041 bytes 08:48:06]File: CITATION [ 12% 26392 bytes 08:48:06] Processing Rd.rds (22.09kB) File: CITATION [ 17% 26392 bytes 08:48:06]File: CITATION [ 17% 49013 bytes 08:48:06] Processing demo.rds (0.25kB) File: CITATION [ 21% 49013 bytes 08:48:06]File: CITATION [ 21% 49266 bytes 08:48:06] Processing features.rds (0.12kB) File: CITATION [ 25% 49266 bytes 08:48:06]File: CITATION [ 25% 49388 bytes 08:48:06] Processing hsearch.rds (22.92kB) File: CITATION [ 29% 49388 bytes 08:48:06]File: CITATION [ 29% 72853 bytes 08:48:06] Processing links.rds (13.24kB) File: CITATION [ 33% 72853 bytes 08:48:06]File: CITATION [ 33% 86411 bytes 08:48:06] Processing package.rds (0.56kB) File: CITATION [ 38% 86411 bytes 08:48:06]File: CITATION [ 38% 86981 bytes 08:48:06] Processing Rprofile (7.47kB) File: CITATION [ 42% 86981 bytes 08:48:06]File: CITATION [ 42% 94627 bytes 08:48:06] Processing base (5.32kB) File: base [ 46% 94627 bytes 08:48:06]File: base [ 46% 100076 bytes 08:48:06] Processing base.rdb (1064.85kB) File: base [ 50% 100076 bytes 08:48:06]File: base [ 50% 1190481 bytes 08:48:06] Processing base.rdx (13.77kB) File: base [ 54% 1190481 bytes 08:48:06]File: base [ 54% 1204581 bytes 08:48:06] Processing error.catching.R (3.29kB) File: base [ 58% 1204581 bytes 08:48:06]File: base [ 58% 1207948 bytes 08:48:06] Processing is.things.R (4.69kB) File: base [ 62% 1207948 bytes 08:48:06]File: base [ 62% 1212746 bytes 08:48:06] Processing recursion.R (2.07kB) File: base [ 67% 1212746 bytes 08:48:06]File: base [ 67% 1214861 bytes 08:48:06] Processing scoping.R (1.52kB) File: base [ 71% 1214861 bytes 08:48:06]File: base [ 71% 1216421 bytes 08:48:06] Processing AnIndex (36.48kB) File: base [ 75% 1216421 bytes 08:48:06]File: base [ 75% 1253774 bytes 08:48:06] Processing aliases.rds (12.37kB) File: base [ 79% 1253774 bytes 08:48:06]File: base [ 79% 1266440 bytes 08:48:06] Processing base.rdb (2306.09kB) File: base [ 83% 1266440 bytes 08:48:06]File: base [ 83% 3627877 bytes 08:48:06] Processing base.rdx (9.11kB) File: base.rdx [ 88% 3627877 bytes 08:48:06]File: base.rdx [ 88% 3637201 bytes 08:48:06] Processing paths.rds (3.10kB) File: base.rdx [ 92% 3637201 bytes 08:48:06]File: base.rdx [ 92% 3640376 bytes 08:48:06] Processing 00Index.html (151.15kB) File: base.rdx [ 96% 3640376 bytes 08:48:06]File: base.rdx [ 96% 3795155 bytes 08:48:06] Processing R.css (1.80kB) File: R.css [100% 3795155 bytes 08:48:06]File: R.css [100% 3796999 bytes 08:48:06]> setLabel(sb, "file", "") > update(sb) File: [100% 3796999 bytes 08:48:06]> cat("\n") > > ## Odds and ends > print(getLabel(sb, "progress")) [1] 100 > print(newline(sb)) NULL > updateLabels(sb) File: [100% 3796999 bytes 08:48:06]> > > proc.time() user system elapsed 0.37 0.10 0.43