set disposition to OPEN_ALWAYS for write and read-write modes (replaces patch 1836605)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50296 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -44,16 +44,19 @@ int wxCRT_Open(const wxChar *filename, int oflag, int WXUNUSED(pmode))
|
|||||||
{
|
{
|
||||||
access = GENERIC_READ;
|
access = GENERIC_READ;
|
||||||
shareMode = FILE_SHARE_READ|FILE_SHARE_WRITE;
|
shareMode = FILE_SHARE_READ|FILE_SHARE_WRITE;
|
||||||
disposition |= OPEN_EXISTING;
|
disposition = OPEN_EXISTING;
|
||||||
}
|
}
|
||||||
else if ((oflag & (O_RDONLY | O_WRONLY | O_RDWR)) == O_WRONLY)
|
else if ((oflag & (O_RDONLY | O_WRONLY | O_RDWR)) == O_WRONLY)
|
||||||
{
|
{
|
||||||
access = GENERIC_WRITE;
|
access = GENERIC_WRITE;
|
||||||
|
disposition = OPEN_ALWAYS;
|
||||||
}
|
}
|
||||||
else if ((oflag & (O_RDONLY | O_WRONLY | O_RDWR)) == O_RDWR)
|
else if ((oflag & (O_RDONLY | O_WRONLY | O_RDWR)) == O_RDWR)
|
||||||
{
|
{
|
||||||
access = GENERIC_READ|GENERIC_WRITE;
|
access = GENERIC_READ|GENERIC_WRITE;
|
||||||
|
disposition = OPEN_ALWAYS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oflag & O_APPEND)
|
if (oflag & O_APPEND)
|
||||||
{
|
{
|
||||||
if ( wxFile::Exists(filename) )
|
if ( wxFile::Exists(filename) )
|
||||||
@@ -62,16 +65,16 @@ int wxCRT_Open(const wxChar *filename, int oflag, int WXUNUSED(pmode))
|
|||||||
shareMode = FILE_SHARE_READ;
|
shareMode = FILE_SHARE_READ;
|
||||||
disposition = OPEN_EXISTING;
|
disposition = OPEN_EXISTING;
|
||||||
}
|
}
|
||||||
//else: fall through as write_append is the same as write if the
|
|
||||||
// file doesn't exist
|
|
||||||
else
|
else
|
||||||
|
{
|
||||||
oflag |= O_TRUNC;
|
oflag |= O_TRUNC;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (oflag & O_TRUNC)
|
if (oflag & O_TRUNC)
|
||||||
{
|
{
|
||||||
access |= GENERIC_WRITE;
|
access |= GENERIC_WRITE;
|
||||||
shareMode = 0;
|
shareMode = 0;
|
||||||
disposition = (oflag & O_CREAT) ? CREATE_ALWAYS : TRUNCATE_EXISTING;
|
disposition = oflag & O_CREAT ? CREATE_ALWAYS : TRUNCATE_EXISTING;
|
||||||
}
|
}
|
||||||
else if (oflag & O_CREAT)
|
else if (oflag & O_CREAT)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user