From hb at maths.lth.se  Sat Feb 18 20:33:49 2006
From: hb at maths.lth.se (Henrik Bengtsson)
Date: Sat, 18 Feb 2006 20:33:49 +0100
Subject: [Rd] file.info() on WinXP/NTFS > 2Gb
Message-ID: <59d7961d0602181133r2e22ccechdafb31aaf8e85b47@mail.gmail.com>

Hi,

on WinXP Pro SP2 with NTFS, I noticed that file.info() under
Rv2.2.1pat (2006-02-09) does not report the correct file size if the
file is >= 2^31 bytes (2GB).   Is this problem known?  Is this related
to the note in ?file.info:

"Some (broken) systems allow files of more than 2Gb to be created but
not accessed by the 'stat' system call.  Such files will show up as
non-readable (and very likely not be readable by any of R's input
functions)."

Example:

# Create a 2Gb(!) file, report file.info()$size, and remove the file.

fname <- "tmp.Rbin";
con <- file(fname, open="w+b");
size <- 2^31-1; # OK
size <- 2^31;    # Not OK
seek(con, where=size-1, rw="write");
writeBin(con=con, as.integer(0), size=1);
close(con);
print(file.info(fname)$size);
file.remove(fname);

With size = c(2^31-1,2^31), file.info() reports file size
c(2147483647,-2147483648).  This looks to me like a non-signed to
signed integer case.

Note that the above code does indeed create files >2Gb on WinXP with
NTFS; I've created files about 6Gb this way.

BTW, about seek() on Windows:  I noticed the warning about using
seek() on Windows (see ?seek): "We have found so many errors in the
Windows implementation of file positioning that users are advised to
use it only at their own risk, and asked not to waste the R
developers' time with bug reports on Windows' deficiencies.".  Not
going to bug report, but I haven't noticed any problems this far. 
What errors/symptoms are expected? Is regardless of file system used,
e.g. FAT, NTFS?

Thanks

Henrik



[Rd] file.info() on WinXP/NTFS > 2Gb
Henrik Bengtsson