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
commit9ae2962cf285589912f13a04f23ed8caee388774 (patch)
tree44cd6edef05803aca68f583d991b4139f8f9ace0 /file.c
parente332544d62b20eb2ff6f4d6fad367cdf4a5df475 (diff)
downloadruby-9ae2962cf285589912f13a04f23ed8caee388774.tar.gz
ruby-9ae2962cf285589912f13a04f23ed8caee388774.tar.xz
ruby-9ae2962cf285589912f13a04f23ed8caee388774.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/branches/ruby_1_8@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 790b0d3a2..544604c7f 100644
--- a/file.c
+++ b/file.c
@@ -2232,10 +2232,16 @@ rb_file_s_rename(klass, from, 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__)