mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* file.c (rb_thread_flock): ERROR_NOT_LOCKED is not an error on Cygwin.
In such situation, flock() should return 0. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9903 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3007dab16f
commit
895778951e
2 changed files with 25 additions and 3 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Mon Feb 6 16:02:51 2006 WATANABE Hirofumi <eban@ruby-lang.org>
|
||||||
|
|
||||||
|
* file.c (rb_thread_flock): ERROR_NOT_LOCKED is not an error on Cygwin.
|
||||||
|
In such situation, flock() should return 0.
|
||||||
|
|
||||||
Mon Feb 6 00:14:57 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Mon Feb 6 00:14:57 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* enum.c (enum_find_index): a new method Enumerable#find_index.
|
* enum.c (enum_find_index): a new method Enumerable#find_index.
|
||||||
|
|
23
file.c
23
file.c
|
@ -12,6 +12,9 @@
|
||||||
|
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
|
//#ifdef __CYGWIN__
|
||||||
|
//#include <windows.h>
|
||||||
|
//#endif
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include "missing/file.h"
|
#include "missing/file.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -2178,7 +2181,7 @@ rb_file_s_rename(VALUE klass, VALUE from, VALUE to)
|
||||||
dst = StringValueCStr(to);
|
dst = StringValueCStr(to);
|
||||||
if (rename(src, dst) < 0) {
|
if (rename(src, dst) < 0) {
|
||||||
#if defined __CYGWIN__
|
#if defined __CYGWIN__
|
||||||
extern unsigned long __attribute__((stdcall)) GetLastError();
|
extern unsigned long __attribute__((stdcall)) GetLastError(void);
|
||||||
errno = GetLastError(); /* This is a Cygwin bug */
|
errno = GetLastError(); /* This is a Cygwin bug */
|
||||||
#elif defined DOSISH && !defined _WIN32
|
#elif defined DOSISH && !defined _WIN32
|
||||||
if (errno == EEXIST
|
if (errno == EEXIST
|
||||||
|
@ -3039,7 +3042,19 @@ rb_file_truncate(VALUE obj, VALUE len)
|
||||||
# define LOCK_UN 8
|
# define LOCK_UN 8
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
#if 1
|
#ifdef __CYGWIN__
|
||||||
|
#include <winerror.h>
|
||||||
|
static int
|
||||||
|
cygwin_flock(int fd, int op)
|
||||||
|
{
|
||||||
|
int ret = flock(fd, op);
|
||||||
|
if (GetLastError() == ERROR_NOT_LOCKED)
|
||||||
|
ret = 0;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
# define flock(fd, op) cygwin_flock(fd, op)
|
||||||
|
#endif
|
||||||
|
|
||||||
static int
|
static int
|
||||||
rb_thread_flock(int fd, int op, OpenFile *fptr)
|
rb_thread_flock(int fd, int op, OpenFile *fptr)
|
||||||
{
|
{
|
||||||
|
@ -3067,8 +3082,10 @@ rb_thread_flock(int fd, int op, OpenFile *fptr)
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#define flock(fd, op) rb_thread_flock(fd, op, fptr)
|
#ifdef __CYGWIN__
|
||||||
|
# undef flock
|
||||||
#endif
|
#endif
|
||||||
|
#define flock(fd, op) rb_thread_flock(fd, op, fptr)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
|
|
Loading…
Reference in a new issue