4

From ?truncate:

truncate truncates a file opened for writing at its current position. It works only for file connections, and is not implemented on all platforms: on others (including Windows) it will not work for large (> 2Gb) files.

What is the cause of the 2Gb limit on Windows? Does it matter if it's 64bit Windows, or the file system is NTFS? Does the version of Windows matter (XP, 7, 8, 10)?

Is there a built-in R function or a function in some R package that achieves the same effect on Windows as truncate on Unix-like systems?

qed
  • 22,298
  • 21
  • 125
  • 196

1 Answers1

2
  1. According to the source, a missing 64-bit version of the underlying ftruncate system call. It seems that this issue can/will be resolved when the MinGW used to build R is updated.
  2. No.
  3. No.
  4. The Win32 API is called SetEndOfFile, and a GitHub search for CRAN packages found eight hits. Good luck :-)
krlmlr
  • 25,056
  • 14
  • 120
  • 217