Bruno Haible wrote:
The 'immutable' module, so far, worked only on platforms with mmap() and
mprotect(). With this patch, it also works on native Windows.
...
+ if (!CloseHandle (h))
+ {
+ UnmapViewOfFile (mem_w);
+ UnmapViewOfFile (mem_r);
+ CloseHandle (h);
+ return 0;
+ }
+# else
/* Extend the file by size/pagesize pages. */
long new_file_length = file_length + size;
if (ftruncate (file_fd, new_file_length) < 0)
These functions look really nice. I've yet to try them.
I noted FileZilla have similar code in 'aio.cpp', but with
handling of a macOS bug if that is something Gnulib should
handle too:
#if FZ_MAC
// There's a bug on macOS: ftruncate can only be called _once_ on a shared
memory object.
// The manpages do not cover this bug, only XNU's bsd/kern/posix_shm.c
mentions it.
struct stat s;
if (fstat(shm, &s) != 0) {
int err = errno;
engine_.GetLogger().log(logmsg::debug_warning, "fstat failed with error
%d", err);
return false;
}
if (s.st_size < 0 || static_cast<size_t>(s.st_size) < memory_size_)
#endif
// .. then the rest is similar to yours.
Not sure if the "bug" is still there, but the
is code at:
https://svn.filezilla-project.org/filezilla/FileZilla3/trunk/src/engine/aio.cpp?view=markup#l84
--
--gv