summaryrefslogtreecommitdiff
path: root/src/file.cc
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2021-05-28 17:03:06 +1000
committerMaxime Coste <mawww@kakoune.org>2021-05-28 17:03:41 +1000
commite4a23a64faf56b5822fee13d976e038174408238 (patch)
tree16f2198e342de7e1237b98aa5795fe80114632e8 /src/file.cc
parent38f85706ffabe33734a6759a3b19405b755fffb8 (diff)
Support opening files bigger than 2 GiB
The real technical limit is with lines bigger than 2 GiB and buffers with more than 2 Gi lines, refactor buffer loading to make it possible to load those files. Fix an overflow with the hash_data function at the same time
Diffstat (limited to 'src/file.cc')
-rw-r--r--src/file.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/file.cc b/src/file.cc
index a92c6783..89dee9a3 100644
--- a/src/file.cc
+++ b/src/file.cc
@@ -218,8 +218,6 @@ MappedFile::MappedFile(StringView filename)
if (st.st_size == 0)
return;
- else if (st.st_size > std::numeric_limits<int>::max())
- throw runtime_error("file is too big");
data = (const char*)mmap(nullptr, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
if (data == MAP_FAILED)
@@ -238,6 +236,8 @@ MappedFile::~MappedFile()
MappedFile::operator StringView() const
{
+ if (st.st_size > std::numeric_limits<int>::max())
+ throw runtime_error("file is too big");
return { data, (int)st.st_size };
}