R Under development (unstable) (2024-01-23 r85822 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 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. > source("incl/start.R") 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.26.0 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.filesets v2.15.1 successfully loaded. See ?R.filesets for help. Attaching package: 'R.filesets' The following objects are masked from 'package:base': append, readLines > > message("*** GenericDataFile ...") *** GenericDataFile ... > > ## Example files > path <- system.file("exData", "dataSetA,original", package="R.filesets") > print(path) [1] "D:/RCompile/CRANincoming/R-devel/lib/R.filesets/exData/dataSetA,original" > > ## Setting up a file set > ds <- GenericDataFileSet$byPath(path) > print(ds) GenericDataFileSet: Name: dataSetA Tags: original Full name: dataSetA,original Number of files: 11 Names: 1.2(a), 11.2(a), all, ..., fileFF [11] Path (to the first file): ../../lib/R.filesets/exData/dataSetA,original Total file size: 1.90 KiB (1945 bytes) > > df <- ds[[1L]] > print(df) GenericDataFile: Name: 1.2(a) Tags: Full name: 1.2(a) Pathname: ../../lib/R.filesets/exData/dataSetA,original/1.2(a).txt File size: 153 B (153 bytes) > > cat(sprintf("Created on: %s\n", getCreatedOn(df))) Created on: 2024-01-24 17:55:07.131519 > cat(sprintf("Accessed on: %s\n", getLastAccessedOn(df))) Accessed on: 2024-01-24 17:55:07.131519 > > ## Missingness > print(is.na(df)) [1] FALSE > > > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - > # Comparisons > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - > pathT <- file.path(tempdir(), "copy") > ds <- copyTo(ds, path=pathT, overwrite=TRUE) > > df <- ds[[1]] > res <- equals(df, df) > print(res) [1] TRUE > stopifnot(res) > > res <- equals(df, NULL) > print(res) [1] FALSE attr(,"thisFile") [1] "../../../../../temp/RtmpITnHmC/copy/1.2(a).txt" attr(,"reason") [1] "The 'other' is not a GenericDataFile: NULL" > stopifnot(!res) > > res <- equals(df, NA) > print(res) [1] FALSE attr(,"thisFile") [1] "../../../../../temp/RtmpITnHmC/copy/1.2(a).txt" attr(,"reason") [1] "The 'other' is not a GenericDataFile: logical" > stopifnot(!res) > > res <- equals(df, ds) > print(res) [1] FALSE attr(,"thisFile") [1] "../../../../../temp/RtmpITnHmC/copy/1.2(a).txt" attr(,"reason") [1] "The 'other' is not a GenericDataFile: GenericDataFileSet" > stopifnot(!res) > > print(df) GenericDataFile: Name: 1.2(a) Tags: Full name: 1.2(a) Pathname: D:/temp/RtmpITnHmC/copy/1.2(a).txt File size: 153 B (153 bytes) > print(getChecksum(df, verbose=TRUE)) [1] "932b17dafa6774b5a36fd71420ffe706" > print(readChecksum(df)) [1] "932b17dafa6774b5a36fd71420ffe706" > > print(df) GenericDataFile: Name: 1.2(a) Tags: Full name: 1.2(a) Pathname: D:/temp/RtmpITnHmC/copy/1.2(a).txt File size: 153 B (153 bytes) > print(getChecksum(df, force=TRUE, verbose=TRUE)) [1] "932b17dafa6774b5a36fd71420ffe706" > > print(df) GenericDataFile: Name: 1.2(a) Tags: Full name: 1.2(a) Pathname: D:/temp/RtmpITnHmC/copy/1.2(a).txt File size: 153 B (153 bytes) > print(getChecksum(df, write=TRUE, force=TRUE, verbose=TRUE)) [1] "932b17dafa6774b5a36fd71420ffe706" > > print(df) GenericDataFile: Name: 1.2(a) Tags: Full name: 1.2(a) Pathname: D:/temp/RtmpITnHmC/copy/1.2(a).txt File size: 153 B (153 bytes) > print(getChecksum(df, write=FALSE, force=TRUE, verbose=TRUE)) [1] "932b17dafa6774b5a36fd71420ffe706" > > > pathT <- file.path(tempdir(), "foo") > dfC <- copyTo(df, path=pathT, overwrite=TRUE) > print(dfC) GenericDataFile: Name: 1.2(a) Tags: Full name: 1.2(a) Pathname: D:/temp/RtmpITnHmC/foo/1.2(a).txt File size: 153 B (153 bytes) > res <- equals(df, dfC) > print(res) [1] TRUE > stopifnot(res) > mod <- hasBeenModified(dfC) > stopifnot(!mod) > print(getChecksum(dfC)) [1] "932b17dafa6774b5a36fd71420ffe706" > > mod1 <- hasBeenModified(dfC, update=FALSE) > print(mod1) [1] FALSE attr(,"lastModifiedOn") [1] "2024-01-24 17:57:06 CET" attr(,"prevModifiedOn") [1] "2024-01-24 17:57:06 CET" > mod2 <- hasBeenModified(dfC, update=FALSE) > print(mod2) [1] FALSE attr(,"lastModifiedOn") [1] "2024-01-24 17:57:06 CET" attr(,"prevModifiedOn") [1] "2024-01-24 17:57:06 CET" > stopifnot(identical(mod2, mod1)) > > > ## Make sure we can detect differences in timestamps > Sys.sleep(1.5) > raw <- raw(length=getFileSize(dfC)) > writeBin(raw, con=getPathname(dfC)) > print(dfC) GenericDataFile: Name: 1.2(a) Tags: Full name: 1.2(a) Pathname: D:/temp/RtmpITnHmC/foo/1.2(a).txt File size: 153 B (153 bytes) > print(getChecksum(dfC)) [1] "d13b5ffdeb538f15ee1d30f2788601d5" > > res <- equals(df, dfC) > print(res) [1] FALSE attr(,"thisFile") [1] "../../../../../temp/RtmpITnHmC/copy/1.2(a).txt" attr(,"otherFile") [1] "../../../../../temp/RtmpITnHmC/foo/1.2(a).txt" attr(,"reason") [1] "The checksums differ: 932b17dafa6774b5a36fd71420ffe706 != d13b5ffdeb538f15ee1d30f2788601d5" > stopifnot(!res) > > > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - > # Checksum files > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - > print(hasChecksumFile(df)) [1] TRUE > > print(getChecksum(df)) [1] "932b17dafa6774b5a36fd71420ffe706" > print(writeChecksum(df)) [1] "../../../../../temp/RtmpITnHmC/copy/1.2(a).txt.md5" > > dfZ <- getChecksumFile(df, verbose=TRUE) Getting checksum file... Pathname: ../../../../../temp/RtmpITnHmC/copy/1.2(a).txt Detected existing checksum file... Detected existing checksum file...done Getting checksum file...done > print(dfZ) ChecksumFile: Name: 1.2(a).txt Tags: Full name: 1.2(a).txt Pathname: d:/temp/RtmpITnHmC/copy/1.2(a).txt.md5 File size: 32 B (32 bytes) Checksum on record: 932b17dafa6774b5a36fd71420ffe706 > validate(dfZ) > > dfZ <- getChecksumFile(df, force=TRUE) > print(dfZ) ChecksumFile: Name: 1.2(a).txt Tags: Full name: 1.2(a).txt Pathname: d:/temp/RtmpITnHmC/copy/1.2(a).txt.md5 File size: 32 B (32 bytes) Checksum on record: 932b17dafa6774b5a36fd71420ffe706 > validate(dfZ) > > > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - > # copyTo() / renameTo() > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - > message("*** copyTo() / renameTo() on GenericDataFile") *** copyTo() / renameTo() on GenericDataFile > > # Copy it to a temporary directory > path <- tempdir() > dfC <- copyTo(df, path=path, overwrite=TRUE) > > # Sanity check > stopifnot(getPathname(dfC) != getPathname(df)) > stopifnot(equals(dfC, df)) > > # Try to copy it without overwriting nor skipping > fail <- tryCatch({ + copyTo(df, path=path, overwrite=FALSE, skip=FALSE) + FALSE + }, error = function(ex) { TRUE }) > stopifnot(fail) > > # Copy it again by overwriting exiting output > dfC <- copyTo(df, path=path, overwrite=TRUE) > print(dfC) GenericDataFile: Name: 1.2(a) Tags: Full name: 1.2(a) Pathname: D:/temp/RtmpITnHmC/1.2(a).txt File size: 153 B (153 bytes) > # Sanity checks > stopifnot(getPathname(dfC) != getPathname(df), + getChecksum(dfC) == getChecksum(df)) > > ## renameTo() may fail on some test systems. > ## See R.utils Issue #42. > if (FALSE) { + dfR <- renameTo(dfC, getPathname(dfC), verbose=TRUE) + stopifnot(equals(dfR, df)) + + filenameC <- getFilename(dfC) + filenameR <- sprintf("%s.foo", filenameC) + dfR <- renameTo(dfC, filenameR, verbose=TRUE) + print(dfR) + stopifnot(equals(dfR, df)) + + dfC2 <- renameTo(dfR, filenameC, verbose=TRUE) + print(dfC2) + stopifnot(getFilename(dfC2) == filenameC) + stopifnot(equals(dfR, df)) + } > > > # Cleanup > file.remove(getPathname(dfC)) [1] TRUE > > # Sanity checks > stopifnot(!isFile(dfC)) > stopifnot(isFile(df)) > > > message("*** copyTo() / renameTo() on GenericDataFile ... DONE") *** copyTo() / renameTo() on GenericDataFile ... DONE > > > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - > # linkTo() > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - > message("*** linkTo() on GenericDataFile") *** linkTo() on GenericDataFile > > # Link to it in a temporary directory > path <- tempdir() > > # On Windows, necessary privileges are required. If not > # available, generate a warning and not an error. > if (.Platform$OS.type == "windows") { + dfL <- NULL + tryCatch({ + dfL <- linkTo(df, path=path) + }, error = function(ex) { + print(ex) + cat("The above exception was caught but ignored for this package system test\n") + }) + + if (!is.null(dfL)) { + print(dfL) + + # Sanity checks + stopifnot(getChecksum(dfL) == getChecksum(df)) + + # Copy file (via link) - unless a Windows Shortcut link + isWindowsShortcut <- (getPathname(dfL) == getPathname(df)) + if (!isWindowsShortcut) { + dfLC <- copyTo(dfL, path=file.path(path, "foo"), overwrite=TRUE, validate=FALSE) + + if (getPathname(dfLC) == getPathname(df) || + getChecksum(dfLC) != getChecksum(df)) { + print(dfLC) + print(getChecksum(dfLC)) + print(df) + print(getChecksum(df)) + } + + # Sanity checks + stopifnot(getPathname(dfLC) != getPathname(df), + getChecksum(dfLC) == getChecksum(df)) + # Cleanup + file.remove(getPathname(dfLC)) + # Sanity checks + stopifnot(!isFile(dfLC)) + stopifnot(isFile(dfL)) + stopifnot(isFile(df)) + # Cleanup + file.remove(getPathname(dfL)) + } else { + # Done with the Windows Shortcut link + dfL <- NULL + } + } + } else { + dfL <- linkTo(df, path=path) + print(dfL) + + # Sanity checks + stopifnot(getPathname(dfL) != getPathname(df), + getChecksum(dfL) == getChecksum(df)) + + # Copy file (via link) + dfLC <- copyTo(dfL, path=file.path(path, "foo"), overwrite=TRUE) + # Sanity checks + stopifnot(getPathname(dfLC) != getPathname(df), + getChecksum(dfLC) == getChecksum(df)) + # Cleanup + file.remove(getPathname(dfLC)) + # Sanity checks + stopifnot(!isFile(dfLC)) + stopifnot(isFile(dfL)) + stopifnot(isFile(df)) + + # Cleanup + file.remove(getPathname(dfL)) + } # if (.Platform$OS.type == "windows") Ihre Berechtigungen reichen nicht aus, um diesen Vorgang auszuführen. Warning in system(cmd, intern = intern, wait = wait | intern, show.output.on.console = wait, : running command 'C:\Windows\system32\cmd.exe /c mklink "D:/temp/RtmpITnHmC/1.2(a).txt" "D:/temp/RtmpITnHmC/copy/1.2(a).txt"' had status 1 GenericDataFile: Name: 1.2(a) Tags: Full name: 1.2(a) Pathname: D:/temp/RtmpITnHmC/copy/1.2(a).txt File size: 153 B (153 bytes) > > # Sanity checks > stopifnot(!isFile(dfL)) > stopifnot(isFile(df)) > > > > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - > # Unknown arguments > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - > df <- GenericDataFile(mustExist=FALSE, foobar=42L, .onUnknownArgs="ignore") > df <- GenericDataFile(mustExist=FALSE, foobar=42L, .onUnknownArgs="warning") Warning in GenericDataFile(mustExist = FALSE, foobar = 42L, .onUnknownArgs = "warning") : Unknown arguments: foobar > res <- try(df <- GenericDataFile(mustExist=FALSE, foobar=42L, .onUnknownArgs="error"), silent=TRUE) > stopifnot(inherits(res, "try-error")) > > checksum <- getChecksum(df) > print(checksum) [1] NA > stopifnot(is.na(checksum)) > > > message("*** GenericDataFile ... DONE") *** GenericDataFile ... DONE > > source("incl/end.R") > > proc.time() user system elapsed 4.00 25.32 33.78