Navigation Menu

Skip to content

Commit

Permalink
windows: avoid "stat" name conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Oct 17, 2015
1 parent f34f961 commit 744e1ac
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 1 addition & 3 deletions lib/db.c
Expand Up @@ -33,7 +33,6 @@
#include "grn_report.h"
#include "grn_util.h"
#include <string.h>
#include <sys/stat.h>

typedef struct {
grn_id id;
Expand Down Expand Up @@ -203,10 +202,9 @@ static grn_bool
grn_db_conf_open(grn_ctx *ctx, grn_db *s, const char *path)
{
char conf_path[PATH_MAX];
struct stat status;

grn_snprintf(conf_path, PATH_MAX, PATH_MAX, GRN_DB_CONF_PATH_FORMAT, path);
if (stat(conf_path, &status) == 0) {
if (grn_path_exist(conf_path) == 0) {
s->conf = grn_hash_open(ctx, conf_path);
if (!s->conf) {
ERR(GRN_NO_MEMORY_AVAILABLE,
Expand Down
1 change: 1 addition & 0 deletions lib/grn_util.h
Expand Up @@ -29,6 +29,7 @@ GRN_API grn_rc grn_normalize_offset_and_limit(grn_ctx *ctx, int size, int *offse
GRN_API char *grn_path_separator_to_system(char *dest, char *groonga_path);

int grn_mkstemp(char *path_template);
grn_bool grn_path_exist(const char *path);

#ifdef WIN32
GRN_API UINT grn_windows_encoding_to_code_page(grn_encoding encoding);
Expand Down
7 changes: 7 additions & 0 deletions lib/util.c
Expand Up @@ -1355,6 +1355,13 @@ grn_mkstemp(char *path_template)
}
#endif /* WIN32 */

grn_bool
grn_path_exist(const char *path)
{
struct stat status;
return stat(path, &status) == 0;
}

#ifdef WIN32
UINT
grn_windows_encoding_to_code_page(grn_encoding encoding)
Expand Down

0 comments on commit 744e1ac

Please sign in to comment.