Opened 21 months ago

Closed 20 months ago

Last modified 20 months ago

#6065 closed defect (fixed)

VSIL append mode not correct in windows

Reported by: Lucian Plesea Owned by: warmerdam
Priority: normal Milestone: 2.1.0
Component: default Version: unspecified
Severity: normal Keywords:


The existing code makes append the same as write, other than seeking to the end of the file on open. See patch for cpl_vsil_win32.cpp with corrected code.

Attachments (1)

cpl_vsil_win32.patch (806 bytes) - added by Lucian Plesea 21 months ago.
Patch for port/cpl_vsil_win32.cpp

Download all attachments as: .zip

Change History (7)

comment:1 Changed 21 months ago by Even Rouault

I'd appreciat if you could add explicit parenthesis in the following expression "FILE_GENERIC_READ | FILE_GENERIC_WRITE FILE_WRITE_DATA;"

Changed 21 months ago by Lucian Plesea

Attachment: cpl_vsil_win32.patch added

Patch for port/cpl_vsil_win32.cpp

comment:2 Changed 21 months ago by Lucian Plesea

Here you go!

comment:3 Changed 21 months ago by Even Rouault

Hum actually looking closer, I don't understand in which situations the patch is necessary. Could you explain a bit more ?

Or is it just to be more POSIX compliant ?

Were there cases where this caused problems in practice ?

I guess there are other /vsi modules where append mode is just implemented as initial seeking. Actually I just now realize that append mode seems to prohibit writing at other places that end even after explicit seeking...

comment:4 Changed 20 months ago by Lucian Plesea

Append mode is not just an initial seek, far from it. It guarantees that the content sent to a file does not gets overwritten, regardless of how many processes use it in append mode at the same time. Without append mode, content may be overwritten. There is also an "a+" mode, that lets you mix random seeks and reads with writes at the end of the file. The classic use is logging from multiple processes.

It doesn't apply to in most /vsi modules other than the ones backed by a real file system.

comment:5 Changed 20 months ago by Even Rouault

Milestone: 2.1.0
Resolution: fixed
Status: newclosed

Thanks for the explanations. Applied in trunk r30082

comment:6 Changed 20 months ago by Even Rouault

trunk r30083 "Fix runtime on Wine < 1.7.4 for file append mode (trunk only, follow up of r30082, #6065)"

Note: See TracTickets for help on using tickets.