Fix last changes in io.cpp for msys2.

- use the same code for msys2 and msvc
- add an option to use a fallback for msys2 if the common code does not compile
This commit is contained in:
jean-pierre charras 2023-05-11 12:51:12 +02:00
parent 03c9b1c202
commit a2ec8bf0a4
1 changed files with 7 additions and 4 deletions

View File

@ -14,19 +14,22 @@
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
* with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <kiplatform/io.h>
#include <wx/string.h>
#include <wx/wxcrt.h>
#include <windows.h>
// Define USE_MSYS2_FALlBACK if the code for _MSC_VER does not compile on msys2
//#define USE_MSYS2_FALLBACK
FILE* KIPLATFORM::IO::SeqFOpen( const wxString& aPath, const wxString& mode )
FILE* KIPLATFORM::IO::SeqFOpen( const wxString& aPath, const wxString& aMode )
{
#ifdef _MSC_VER
#if defined( _MSC_VER ) || !defined( USE_MSYS2_FALLBACK )
// We need to use the win32 api to setup a file handle with sequential scan flagged
// and pass it up the chain to create a normal FILE stream
HANDLE hFile = INVALID_HANDLE_VALUE;
@ -52,7 +55,7 @@ FILE* KIPLATFORM::IO::SeqFOpen( const wxString& aPath, const wxString& mode )
return NULL;
}
FILE* fp = _fdopen( fd, mode.c_str() );
FILE* fp = _fdopen( fd, aMode.c_str() );
if( !fp )
{