Open NiclasLindgren opened 3 years ago
It should possibly be like this
. . int openModeFlags = 0;
switch (mode[0]) {
case 'a':
dwCreationDisposition = OPEN_ALWAYS;
openModeFlags |= _O_APPEND;
break;
case 'r':
dwCreationDisposition = OPEN_EXISTING;
break;
case 'w':
dwCreationDisposition = CREATE_ALWAYS;
break;
default:
return NULL;
}
if (mode[1] != 0) {
switch (mode[1]) {
case 't':
openModeFlags |= _O_TEXT;
break;
}
}
. . .
int fd = _open_osfhandle((intptr_t)hfile, openModeFlags);
I can make a pull request if you agree
I might be doing something wrong, but when mosquitto starts the when the log file already exists (it was created by mosquitto) it won't log to the end of the file.
If I add code to fclose and fopen the file (instead of mosquitto__fopen) it will work, looking at the code in "restrict_read" path you find that int fd = _open_osfhandle((intptr_t)hfile, 0);
should be (if "a" is used, or OPEN_ALWAYS)
Maybe this should be on a mailing list of sorts as a question first.