From c2520dab54cf18955b6d351a6d9f7b6d32a14c3c Mon Sep 17 00:00:00 2001 From: clemahieu <clemahieu@gmail.com> Date: Sun, 15 Mar 2015 20:45:15 -0500 Subject: [PATCH] Allocating sparse files on windows. --- liblmdb/mdb.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/liblmdb/mdb.c b/liblmdb/mdb.c index 984a5bdd16..98b69fcc4b 100644 --- a/liblmdb/mdb.c +++ b/liblmdb/mdb.c @@ -4682,6 +4682,10 @@ mdb_env_open(MDB_env *env, const char *path, unsigned int flags, mdb_mode_t mode mode = FILE_ATTRIBUTE_NORMAL; env->me_fd = CreateFile(dpath, oflags, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, len, mode, NULL); + DWORD actual; + if (!DeviceIoControl(env->me_fd, FSCTL_SET_SPARSE, NULL, 0, + NULL, 0, &actual, NULL)) + ; // If the file is not sparsed, it will allocate the full environment #else if (F_ISSET(flags, MDB_RDONLY)) oflags = O_RDONLY;