First Commit
This commit is contained in:
commit
8a6c7106e3
1312 files changed
+425396
No files matched your search
+18
@@ -0,0 +1,18 @@
|
||||
#ifndef OSMIUM_TEST_CRC_HPP
|
||||
#define OSMIUM_TEST_CRC_HPP
|
||||
|
||||
#ifdef OSMIUM_TEST_CRC_USE_BOOST
|
||||
|
||||
/* Use the CRC32 implementation from boost. */
|
||||
#include <boost/crc.hpp>
|
||||
using crc_type = boost::crc_32_type;
|
||||
|
||||
#else
|
||||
|
||||
/* Use the CRC32 implementation from zlib. */
|
||||
#include <osmium/osm/crc_zlib.hpp>
|
||||
using crc_type = osmium::CRC_zlib;
|
||||
|
||||
#endif
|
||||
|
||||
#endif // OSMIUM_TEST_CRC_HPP
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
|
||||
#ifndef _WIN32
|
||||
# include <unistd.h>
|
||||
# include <fcntl.h>
|
||||
|
||||
// This function counts the number of open file descriptors. It is used in
|
||||
// some tests to make sure that we are not leaking file descriptors.
|
||||
inline int count_fds() noexcept {
|
||||
int count = 0;
|
||||
for (int fd = 0; fd < 100; ++fd) {
|
||||
if (fcntl(fd, F_GETFD) == 0) {
|
||||
++count;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
#else
|
||||
// Dummy for Windows which doesn't have fcntl
|
||||
inline int count_fds() noexcept {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
inline std::string with_data_dir(const char* filename) {
|
||||
const char* data_dir = getenv("OSMIUM_TEST_DATA_DIR");
|
||||
|
||||
std::string result;
|
||||
if (data_dir) {
|
||||
result = data_dir;
|
||||
result += '/';
|
||||
}
|
||||
|
||||
result += filename;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
Reference in new issue
Block a user