Navigation Menu

Skip to content

Commit

Permalink
windows: use _unlink() on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Apr 15, 2015
1 parent 120ee87 commit fd20a88
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 10 deletions.
1 change: 0 additions & 1 deletion build/ac_macros/check_functions.m4
Expand Up @@ -14,5 +14,4 @@ AC_CHECK_FUNCS(read)
AC_CHECK_FUNCS(strcasecmp)
AC_CHECK_FUNCS(strncasecmp)
AC_CHECK_FUNCS(strtoull)
AC_CHECK_FUNCS(unlink)
AC_CHECK_FUNCS(write)
1 change: 0 additions & 1 deletion config.h.cmake
Expand Up @@ -154,7 +154,6 @@
#cmakedefine HAVE_STRCASECMP
#cmakedefine HAVE_STRNCASECMP
#cmakedefine HAVE_STRTOULL
#cmakedefine HAVE_UNLINK
#cmakedefine HAVE_WRITE
#cmakedefine HAVE_PTHREAD_MUTEXATTR_SETPSHARED
#cmakedefine HAVE_PTHREAD_CONDATTR_SETPSHARED
6 changes: 6 additions & 0 deletions include/groonga/portability.h
Expand Up @@ -77,4 +77,10 @@
# define grn_strdup_raw(string) strdup((string))
#endif /* WIN32 */

#ifdef WIN32
# define grn_unlink(filename) _unlink((filename))
#else /* WIN32 */
# define grn_unlink(filename) unlink((filename))
#endif /* WIN32 */

#endif /* GROONGA_PORTABILITY_H */
2 changes: 1 addition & 1 deletion lib/dat.cpp
Expand Up @@ -70,7 +70,7 @@ bool
grn_dat_remove_file(grn_ctx *ctx, const char *path)
{
struct stat stat;
return !::stat(path, &stat) && !unlink(path);
return !::stat(path, &stat) && !grn_unlink(path);
}

grn_rc
Expand Down
3 changes: 0 additions & 3 deletions lib/grn.h
Expand Up @@ -122,9 +122,6 @@
# if !defined(__GNUC__) && _MSC_VER < 1500
# define vsnprintf(str, size, format, ap) _vsnprintf(str, size, format, ap)
# endif /* !defined(__GNUC__) && _MSC_VER < 1500 */
# ifndef HAVE_UNLINK
# define unlink(pathname) _unlink(pathname)
# endif
# define getpid() _getpid()
# if !defined(__GNUC__) && _MSC_VER < 1400
# define fstat(fd, buf) _fstat(fd, buf)
Expand Down
4 changes: 2 additions & 2 deletions lib/ii.c
Expand Up @@ -7826,7 +7826,7 @@ grn_ii_buffer_commit(grn_ctx *ctx, grn_ii_buffer *ii_buffer)
"tmpfile_size:%" GRN_FMT_INT64D " > total_chunk_size:%" GRN_FMT_SIZE,
ii_buffer->filepos, ii_buffer->total_chunk_size);
GRN_CLOSE(ii_buffer->tmpfd);
unlink(ii_buffer->tmpfpath);
grn_unlink(ii_buffer->tmpfpath);
ii_buffer->tmpfd = -1;
return ctx->rc;
}
Expand All @@ -7845,7 +7845,7 @@ grn_ii_buffer_close(grn_ctx *ctx, grn_ii_buffer *ii_buffer)
}
if (ii_buffer->tmpfd != -1) {
GRN_CLOSE(ii_buffer->tmpfd);
unlink(ii_buffer->tmpfpath);
grn_unlink(ii_buffer->tmpfpath);
}
if (ii_buffer->block_buf) {
GRN_FREE(ii_buffer->block_buf);
Expand Down
4 changes: 2 additions & 2 deletions lib/io.c
Expand Up @@ -718,7 +718,7 @@ grn_io_remove(grn_ctx *ctx, const char *path)
if (stat(path, &s)) {
SERR("stat");
return ctx->rc;
} else if (unlink(path)) {
} else if (grn_unlink(path)) {
ERRNO_ERR(path);
return ctx->rc;
} else {
Expand All @@ -727,7 +727,7 @@ grn_io_remove(grn_ctx *ctx, const char *path)
for (fno = 1; ; fno++) {
gen_pathname(path, buffer, fno);
if (!stat(buffer, &s)) {
if (unlink(buffer)) {
if (grn_unlink(buffer)) {
ERRNO_ERR(buffer);
}
} else {
Expand Down

0 comments on commit fd20a88

Please sign in to comment.