Skip to content

Commit 8294c6f

Browse files
committed
update error message for nrow and mmap
1 parent 3866b6d commit 8294c6f

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/fread.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,9 +1575,16 @@ int freadMain(freadMainArgs _args)
15751575
CloseHandle(hFile); // see https://msdn.microsoft.com/en-us/library/windows/desktop/aa366537(v=vs.85).aspx
15761576
if (mmp == NULL) {
15771577
#endif
1578-
int nbit = 8 * sizeof(char*); // #nocov
1579-
STOP(_("Opened %s file ok but could not memory map it. This is a %dbit process. %s."), filesize_to_str(fileSize), nbit, // # nocov
1580-
nbit <= 32 ? _("Please upgrade to 64bit") : _("There is probably not enough contiguous virtual memory available")); // # nocov
1578+
// # nocov start
1579+
int nbit = 8 * sizeof(char*);
1580+
if (nrowLimit < INT64_MAX) {
1581+
STOP(_("Opened %s file ok but could not memory map it. This is a %dbit process. Since you specified nrows=%"PRId64", try wrapping the file in a connection: fread(file('filename'), nrows=%"PRId64")."),
1582+
filesize_to_str(fileSize), nbit, nrowLimit, nrowLimit);
1583+
} else {
1584+
STOP(_("Opened %s file ok but could not memory map it. This is a %dbit process. %s."), filesize_to_str(fileSize), nbit,
1585+
nbit <= 32 ? _("Please upgrade to 64bit") : _("There is probably not enough contiguous virtual memory available"));
1586+
}
1587+
// # nocov end
15811588
}
15821589
sof = (const char*) mmp;
15831590
if (verbose) DTPRINT(_(" Memory mapped ok\n"));

0 commit comments

Comments
 (0)