2018-12-13 22:21:27 +00:00
|
|
|
/*
|
2020-01-28 14:32:34 +00:00
|
|
|
* (C) Copyright 2005- ECMWF.
|
2018-12-13 22:21:27 +00:00
|
|
|
*
|
|
|
|
* This software is licensed under the terms of the Apache Licence Version 2.0
|
|
|
|
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
|
|
|
*
|
|
|
|
* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
|
|
|
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Common tigge functions
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "tigge_tools.h"
|
2019-01-07 16:13:48 +00:00
|
|
|
#include "eccodes_windef.h"
|
2018-12-13 22:21:27 +00:00
|
|
|
|
2019-01-07 16:13:48 +00:00
|
|
|
#ifndef ECCODES_ON_WINDOWS
|
|
|
|
#include <dirent.h>
|
|
|
|
#else
|
|
|
|
#include <direct.h>
|
|
|
|
#include <io.h>
|
|
|
|
#endif
|
|
|
|
|
2018-12-13 22:21:27 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
extern void validate(const char* path);
|
|
|
|
|
2019-01-07 16:13:48 +00:00
|
|
|
#ifndef ECCODES_ON_WINDOWS
|
2018-12-13 22:21:27 +00:00
|
|
|
void scan(const char* name)
|
|
|
|
{
|
|
|
|
DIR *dir;
|
|
|
|
if((dir = opendir(name)) != NULL)
|
|
|
|
{
|
|
|
|
struct dirent* e;
|
|
|
|
char tmp[1024];
|
|
|
|
while( (e = readdir(dir)) != NULL)
|
|
|
|
{
|
|
|
|
if(e->d_name[0] == '.') continue;
|
2022-11-10 19:18:43 +00:00
|
|
|
snprintf(tmp, 1024, "%s/%s",name,e->d_name);
|
2018-12-13 22:21:27 +00:00
|
|
|
scan(tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
closedir(dir);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
validate(name);
|
|
|
|
}
|
|
|
|
}
|
2019-01-07 16:13:48 +00:00
|
|
|
#else
|
|
|
|
void scan(const char* name)
|
|
|
|
{
|
|
|
|
struct _finddata_t fileinfo;
|
|
|
|
intptr_t handle;
|
2019-01-11 12:49:31 +00:00
|
|
|
char tmp[1024];
|
2022-11-10 19:18:43 +00:00
|
|
|
snprintf(tmp, 1024, "%s/*", name);
|
2019-01-11 12:49:31 +00:00
|
|
|
if((handle = _findfirst(tmp, &fileinfo)) != -1)
|
2019-01-07 16:13:48 +00:00
|
|
|
{
|
|
|
|
do {
|
2019-01-11 12:49:31 +00:00
|
|
|
if(fileinfo.name[0] != '.') {
|
2022-11-10 19:18:43 +00:00
|
|
|
snprintf(tmp, 1024, "%s/%s", name, fileinfo.name);
|
2019-01-11 12:49:31 +00:00
|
|
|
scan(tmp);
|
2019-01-07 16:13:48 +00:00
|
|
|
}
|
|
|
|
} while(!_findnext(handle, &fileinfo));
|
2019-01-11 12:49:31 +00:00
|
|
|
|
|
|
|
_findclose(handle);
|
2019-01-07 16:13:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
validate(name);
|
|
|
|
}
|
|
|
|
#endif
|