Skip to content

Commit 2a76e78

Browse files
committed
eban
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_4@883 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent bcb17d8 commit 2a76e78

File tree

4 files changed

+60
-2
lines changed

4 files changed

+60
-2
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
Wed Aug 9 13:24:25 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
2+
3+
* win32/win32.[ch]: emulate rename(2).
4+
15
Mon Aug 7 13:59:12 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
26

37
* regex.c (re_match): check for stack depth was needed.

version.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#define RUBY_VERSION "1.4.6"
2-
#define RUBY_RELEASE_DATE "2000-08-01"
2+
#define RUBY_RELEASE_DATE "2000-08-09"
33
#define RUBY_VERSION_CODE 146
4-
#define RUBY_RELEASE_CODE 20000801
4+
#define RUBY_RELEASE_CODE 20000809

win32/win32.c

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2371,3 +2371,51 @@ win32_getenv(const char *name)
23712371

23722372
return curitem;
23732373
}
2374+
2375+
int
2376+
myrename(const char *oldpath, const char *newpath)
2377+
{
2378+
int res = 0;
2379+
int oldatts;
2380+
int newatts;
2381+
2382+
oldatts = GetFileAttributes(oldpath);
2383+
newatts = GetFileAttributes(newpath);
2384+
2385+
if (oldatts == -1) {
2386+
printf("file to move doesn't exist");
2387+
return -1;
2388+
}
2389+
2390+
if (newatts != -1 && newatts & FILE_ATTRIBUTE_READONLY)
2391+
SetFileAttributesA(newpath, newatts & ~ FILE_ATTRIBUTE_READONLY);
2392+
2393+
if (!MoveFile(oldpath, newpath))
2394+
res = -1;
2395+
2396+
if (res == 0 || (GetLastError() != ERROR_ALREADY_EXISTS
2397+
&& GetLastError() != ERROR_FILE_EXISTS))
2398+
goto done;
2399+
2400+
if (IsWinNT()) {
2401+
if (MoveFileEx(oldpath, newpath, MOVEFILE_REPLACE_EXISTING))
2402+
res = 0;
2403+
} else {
2404+
for (;;) {
2405+
if (!DeleteFile(newpath) && GetLastError() != ERROR_FILE_NOT_FOUND)
2406+
break;
2407+
else if (MoveFile(oldpath, newpath)) {
2408+
res = 0;
2409+
break;
2410+
}
2411+
}
2412+
}
2413+
2414+
done:
2415+
if (res)
2416+
errno = GetLastError();
2417+
else
2418+
SetFileAttributes(newpath, oldatts);
2419+
2420+
return res;
2421+
}

win32/win32.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ extern struct protoent * mygetprotobynumber(int);
200200
extern struct servent * mygetservbyname(char *, char *);
201201
extern struct servent * mygetservbyport(int, char *);
202202
extern char *win32_getenv(const char *);
203+
extern int myrename(const char *, const char *);
203204

204205
extern int chown(const char *, int, int);
205206
extern int link(char *, char *);
@@ -401,4 +402,9 @@ extern char *mystrerror(int);
401402
#endif
402403
#define getenv win32_getenv
403404

405+
#ifdef rename
406+
#undef rename
407+
#endif
408+
#define rename myrename
409+
404410
#endif

0 commit comments

Comments
 (0)