diff --git a/inst/tests/benchmark.Rraw b/inst/tests/benchmark.Rraw index 246a1d5daa..e958973145 100644 --- a/inst/tests/benchmark.Rraw +++ b/inst/tests/benchmark.Rraw @@ -104,7 +104,7 @@ if (FALSE) { d = "/tmp/" f = paste0(d,"test.txt") system.time(fwrite(DT, f, nThread=1)) - file.info(f)$size/1024^3 + file.size(f)/1024^3 unlink(f) # ensure progress meter itself isn't taking time; e.g. too many calls to time() or clock() system.time(fwrite(DT, f, showProgress=FALSE, nThread=1)) @@ -116,7 +116,7 @@ if (FALSE) { unlink(f) unlink(f2) system.time(fwrite(DT, f2)) # try again, should work now space free'd - file.info(f2)$size/1024^3 + file.size(f2)/1024^3 unlink(f2) } @@ -143,7 +143,7 @@ DT <- as.data.table(m) f <- tempfile() system.time(fwrite(DT, f, eol='\n', quote=TRUE)) # eol fixed so size test passes on Windows system.time(fwrite(DT, f, eol='\n', quote=TRUE)) # run again to force seg fault -test(1664, abs(file.info(f)$size %/% 100000 - 62) <= 1.5) # file size appears to be 34 bytes bigger on Windows (6288931 vs 6288965) +test(1664, abs(file.size(f) %/% 100000 - 62) <= 1.5) # file size appears to be 34 bytes bigger on Windows (6288931 vs 6288965) unlink(f) n=10000 @@ -327,7 +327,7 @@ if (getDTthreads() == 1L) { } else { N = if (TRUE) 2e6 else 1e9 # offline speed check fwrite(data.table(A=sample(10,N,replace=TRUE)), f<-tempfile()) - test(1760.1, file.info(f)$size > 4*1024*1024) + test(1760.1, file.size(f) > 4*1024*1024) test(1760.2, fread(f, verbose=TRUE, nThread=2), output="using 2 threads") unlink(f) } diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index 5aa435cf07..3a446a8136 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -9768,16 +9768,16 @@ if (!haszlib()) { test(1658.421, fwrite(DT, file=f1<-tempfile(fileext=".gz"), verbose=TRUE), NULL, output="args.nrow=200 args.ncol=2.*maxLineLen=5[12].*Writing 200 rows in 1 batches of 200 rows.*nth=1") # [12] for Windows where eolLen==2 test(1658.422, fwrite(DT, file=f2<-tempfile()), NULL) - test(1658.423, file.info(f1)$size < file.info(f2)$size) # 74 < 804 (file.size() isn't available in R 3.1.0) + test(1658.423, file.size(f1) < file.size(f2)) # 74 < 804 if (test_R.utils) test(1658.43, fread(f1), DT) # use fread to decompress gz (works cross-platform) fwrite(DT, file=f3<-tempfile(), compress="gzip") # compress to filename not ending .gz fwrite(DT, file=f4<-tempfile(), compress="gzip", compressLevel=1) # test compressLevel fwrite(DT, file=f5<-tempfile(), compress="gzip", compressLevel=9) # col.names=FALSE must not disable gzip header, #6852 fwrite(DT, file=f6<-tempfile(), compress="gzip", col.names=FALSE) - test(1658.441, file.info(f3)$size, file.info(f1)$size) - test(1658.442, file.info(f4)$size >= file.info(f1)$size) - test(1658.443, file.info(f1)$size >= file.info(f5)$size) + test(1658.441, file.size(f3), file.size(f1)) + test(1658.442, file.size(f4) >= file.size(f1)) + test(1658.443, file.size(f1) >= file.size(f5)) if (test_R.utils) test(1658.444, fread(f6, col.names = c("a", "b")), DT) unlink(c(f1,f2,f3,f4,f5,f6)) } @@ -9803,7 +9803,7 @@ fwrite(DT, f2, bom=TRUE) f2con = file(f2, encoding="UTF-8") test(1658.51, length(readLines(f2con)), 27L) close(f2con) -test(1658.52, file.info(f1)$size, file.info(f2)$size) +test(1658.52, file.size(f1), file.size(f2)) unlink(c(f1, f2)) # compression error -5 due to only 3 bytes (bom) in first block; #3599 @@ -11326,7 +11326,7 @@ line255 = paste(rep("123,456,789,0AB",16),collapse=",") test(1770.1, nchar(line255), 255L) for (i in 1:256) cat(line255, "\x0A", sep="", file=ff) # use \n line ending even on Windows close(ff) -test(1770.2, file.info(f)$size, 65536) +test(1770.2, file.size(f), 65536) test(1770.3, fread(f)[256,V64], "0AB") test(1770.4, fread(f, skip="spam"), error="not found in input") unlink(f) @@ -11335,7 +11335,7 @@ ff = file(f<-tempfile(), open="wb") for (i in 1:255) cat(line255, "\x0A", sep="", file=ff) cat(line255, "C", sep="", file=ff) close(ff) -test(1770.5, file.info(f)$size, 65536) +test(1770.5, file.size(f), 65536) test(1770.6, fread(f)[256,V64], "0ABC") test(1770.7, fread(f, skip="spam"), error="not found in input") unlink(f) @@ -11657,14 +11657,14 @@ for (mul in c(16, 128, 512, 1024, 2048)) { cat(strrep("1234,5678,9012,3456,7890,abcd,4\x0A", mul), file=ff) close(ff) DT = data.table(V1=rep(1234L, mul), V2=5678L, V3=9012L, V4=3456L, V5=7890L, V6="abcd", V7=4L) - test(1801 + log2(mul)/100 + 0.001, file.info(f)$size, mul*32, context=sprintf("mul=%d [file size]", mul)) + test(1801 + log2(mul)/100 + 0.001, file.size(f), mul*32, context=sprintf("mul=%d [file size]", mul)) test(1801 + log2(mul)/100 + 0.002, fread(f), DT, context=sprintf("mul=%d [fread]", mul)) } # Test without the newline ff = file(f<-tempfile(), open="wb") cat(paste("1", paste(rep("1234,5678,9012,3456,7890,zyxw,4", 128), collapse="\x0A"), sep=""), file=ff) close(ff) -test(1803.1, file.info(f)$size, 4096) +test(1803.1, file.size(f), 4096) DT = data.table(V1=rep(1234L, 128), V2=5678L, V3=9012L, V4=3456L, V5=7890L, V6="zyxw", V7=4L) DT[1, 1] = 11234L test(1803.2, fread(f), DT) diff --git a/man/fread.Rd b/man/fread.Rd index 0ee49fe322..e121cae0d3 100644 --- a/man/fread.Rd +++ b/man/fread.Rd @@ -241,7 +241,7 @@ DT[2,e:=+Inf] DT[3,e:=-Inf] write.table(DT,"test.csv",sep=",",row.names=FALSE,quote=FALSE) -cat("File size (MiB):", round(file.info("test.csv")$size/1024^2),"\n") +cat("File size (MiB):", round(file.size("test.csv")/1024^2),"\n") # 50 MiB (1e6 rows x 6 columns) system.time(DF1 <-read.csv("test.csv",stringsAsFactors=FALSE))