summaryrefslogtreecommitdiffstats
path: root/file.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-08-19 02:29:18 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-08-19 02:29:18 +0000
commit9f0a6b50f9dc8668dc0457eba143a5ea4976a639 (patch)
tree59bd1868ca7ad7afbba55903dd9f72ddcaf6cc5c /file.c
parent583de7951baf7fb0546ef56ecf5e3d9dc0c9099d (diff)
downloadruby-9f0a6b50f9dc8668dc0457eba143a5ea4976a639.tar.gz
ruby-9f0a6b50f9dc8668dc0457eba143a5ea4976a639.tar.xz
ruby-9f0a6b50f9dc8668dc0457eba143a5ea4976a639.zip
* file.c (rb_file_s_rename): use errno if set properly.
fixed: [ruby-dev:29293] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@10747 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r--file.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/file.c b/file.c
index f1527a040..00bc40cd7 100644
--- a/file.c
+++ b/file.c
@@ -2180,10 +2180,16 @@ rb_file_s_rename(VALUE klass, VALUE from, VALUE to)
FilePathValue(to);
src = StringValueCStr(from);
dst = StringValueCStr(to);
+#if defined __CYGWIN__
+ errno = 0;
+#endif
if (rename(src, dst) < 0) {
#if defined __CYGWIN__
extern unsigned long __attribute__((stdcall)) GetLastError(void);
- errno = GetLastError(); /* This is a Cygwin bug */
+ if (errno == 0) { /* This is a bug of old Cygwin */
+ /* incorrect as cygwin errno, but the last resort */
+ errno = GetLastError();
+ }
#elif defined DOSISH && !defined _WIN32
if (errno == EEXIST
#if defined (__EMX__)