Skip to content

Commit

Permalink
add mkstemp implementations for tests on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
alex85k committed Aug 25, 2014
1 parent dbf1971 commit 4190c6d
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
42 changes: 42 additions & 0 deletions test/include/win_mkstemp.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* mkstemp.c
*
* Provides a trivial replacement for the POSIX `mkstemp()' function,
* suitable for use in MinGW (Win32) applications.
*
* This file is part of the MinGW32 package set.
*
* Contributed by Keith Marshall <keithmarshall@users.sourceforge.net>
* Patched to VS2013 by alex85k
* THIS SOFTWARE IS NOT COPYRIGHTED
*
* This source code is offered for use in the public domain. You may
* use, modify or distribute it freely.
*
* This code is distributed in the hope that it will be useful but
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
* DISCLAIMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/

#ifndef WIN_MKSTEMP_H
#define WIN_MKSTEMP_H

#include <stdio.h>
#include <fcntl.h>
#include <share.h>

inline int mkstemp( char *templ )
{
int maxtry = 26, rtn = -1;

while( maxtry-- && (rtn < 0) )
{
char *r = _mktemp( templ );
if( r == NULL )
return -1;
rtn = sopen( r, O_RDWR | O_CREAT | O_EXCL | O_BINARY, SH_DENYRW, 0600 );
}
return rtn;
}
#endif
4 changes: 4 additions & 0 deletions test/t/index/test_typed_mmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ using boost::test_tools::output_test_stream;

#include <osmium/index/detail/typed_mmap.hpp>

#ifdef _MSC_VER
#include "win_mkstemp.hpp"
#endif

TEST_CASE("TypedMmap") {

SECTION("Mmap") {
Expand Down

0 comments on commit 4190c6d

Please sign in to comment.