Skip to content

Commit

Permalink
Add a wrapper of grn_win32_base_dir() for plugin
Browse files Browse the repository at this point in the history
grn_plugin_win32_base_dir() is added.
  • Loading branch information
kou committed Oct 11, 2012
1 parent 3314fa9 commit 0a55a6b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
10 changes: 10 additions & 0 deletions include/groonga/plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,16 @@ void grn_plugin_mutex_unlock(grn_ctx *ctx, grn_plugin_mutex *mutex);
grn_obj *grn_plugin_proc_alloc(grn_ctx *ctx, grn_user_data *user_data,
grn_id domain, grn_obj_flags flags);

/*
grn_plugin_win32_base_dir() returns the groonga install directory.
The install directory is computed from the directory that has
`groonga.dll`. You can use the directory to generate install
directory aware path.
It only works on Windows. It returns `NULL` on other platforms.
*/
const char *grn_plugin_win32_base_dir(void);


#ifdef __cplusplus
}
Expand Down
10 changes: 10 additions & 0 deletions lib/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -530,3 +530,13 @@ grn_plugin_proc_alloc(grn_ctx *ctx, grn_user_data *user_data,
{
return grn_proc_alloc(ctx, user_data, domain, flags);
}

const char *
grn_plugin_win32_base_dir(void)
{
#ifdef WIN32
return grn_win32_base_dir();
#else /* WIN32 */
return NULL;
#endif /* WIN32 */
}
4 changes: 1 addition & 3 deletions plugins/query_expanders/tsv.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
/* groonga's internal headers: They should be removed. */
/* for grn_text_fgets() */
#include <str.h>
/* for grn_win32_base_dir() */
#include <util.h>

#include <stdio.h>
#include <string.h>
Expand All @@ -42,7 +40,7 @@ get_system_synonyms_file(void)
char *path;
size_t base_dir_length;

base_dir = grn_win32_base_dir();
base_dir = grn_plugin_win32_base_dir();
base_dir_length = strlen(base_dir);
synonyms_file =
malloc(base_dir_length + strlen("/") + strlen(relative_path) + 1);
Expand Down

0 comments on commit 0a55a6b

Please sign in to comment.