[Groonga-commit] groonga/groonga at 744e1ac [master] windows: avoid "stat" name conflict

Back to archive index

Kouhei Sutou null+****@clear*****
Sat Oct 17 21:06:55 JST 2015


Kouhei Sutou	2015-10-17 21:06:55 +0900 (Sat, 17 Oct 2015)

  New Revision: 744e1ac4ef45f79957aef079218347debd336257
  https://github.com/groonga/groonga/commit/744e1ac4ef45f79957aef079218347debd336257

  Message:
    windows: avoid "stat" name conflict

  Modified files:
    lib/db.c
    lib/grn_util.h
    lib/util.c

  Modified: lib/db.c (+1 -3)
===================================================================
--- lib/db.c    2015-10-17 21:00:52 +0900 (3b7f76e)
+++ lib/db.c    2015-10-17 21:06:55 +0900 (558877a)
@@ -33,7 +33,6 @@
 #include "grn_report.h"
 #include "grn_util.h"
 #include <string.h>
-#include <sys/stat.h>
 
 typedef struct {
   grn_id id;
@@ -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,

  Modified: lib/grn_util.h (+1 -0)
===================================================================
--- lib/grn_util.h    2015-10-17 21:00:52 +0900 (b658786)
+++ lib/grn_util.h    2015-10-17 21:06:55 +0900 (752e4d4)
@@ -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);

  Modified: lib/util.c (+7 -0)
===================================================================
--- lib/util.c    2015-10-17 21:00:52 +0900 (d21b973)
+++ lib/util.c    2015-10-17 21:06:55 +0900 (c99a3ba)
@@ -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)
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index