Windows: tigge: implement windows build

This commit is contained in:
Daniel Tipping 2018-12-12 12:33:10 +00:00
parent e496ae16f6
commit 3232f7a0e8
4 changed files with 73 additions and 5 deletions

View File

@ -25,7 +25,18 @@
#include <string.h>
#include <math.h>
#include <sys/types.h>
#include <dirent.h>
#ifndef ECCODES_ON_WINDOWS
#include <dirent.h>
#else
#include <direct.h>
#include <io.h>
#ifdef _MSC_VER
# define strcasecmp _stricmp
#endif
#endif
#include <assert.h>
#include "tigge_tools.h"

View File

@ -25,9 +25,15 @@
#include <string.h>
#include <math.h>
#include <sys/types.h>
#include <dirent.h>
#include "tigge_tools.h"
#ifndef ECCODES_ON_WINDOWS
#include <dirent.h>
#else
#include <direct.h>
#include <io.h>
#endif
/* #define CHECK(a) check(#a,a) */
#define NUMBER(a) (sizeof(a)/sizeof(a[0]))

View File

@ -25,9 +25,22 @@
#include <string.h>
#include <math.h>
#include <sys/types.h>
#include <dirent.h>
#include <unistd.h>
#ifndef ECCODES_ON_WINDOWS
#include <dirent.h>
#include <unistd.h>
#else
#include <direct.h>
#include <io.h>
#ifndef F_OK
# define F_OK 0
#endif
#ifdef _MSC_VER
# define access(path,mode) _access(path,mode)
#endif
#endif
#define CHECK(a) check(#a,a)

View File

@ -13,14 +13,23 @@
*/
#include "tigge_tools.h"
#include "eccodes_windef.h"
#include <stdlib.h>
#include <sys/types.h>
#include <dirent.h>
#ifndef ECCODES_ON_WINDOWS
#include <dirent.h>
#else
#include <direct.h>
#include <io.h>
#endif
#include <stdio.h>
extern void validate(const char* path);
#ifndef ECCODES_ON_WINDOWS
void scan(const char* name)
{
DIR *dir;
@ -41,3 +50,32 @@ void scan(const char* name)
validate(name);
}
}
#else
// based on similar code in grib_tools.c
static int isWinDir(const struct _finddata_t *fileinfo)
{
if((fileinfo->attrib & 16) == 16)
return 1;
return 0;
}
void scan(const char* name)
{
struct _finddata_t fileinfo;
intptr_t handle;
if((handle = _findfirst(name, &fileinfo)) != -1)
{
char tmp[1024];
do {
if(isWinDir(&fileinfo))
{
if(fileinfo.name[0] != '.') {
sprintf(tmp, "%s/%s", name, fileinfo.name);
scan(tmp);
}
}
} while(!_findnext(handle, &fileinfo));
}
else
validate(name);
}
#endif