Skip to content

Commit

Permalink
eban
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@881 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
eban committed Aug 9, 2000
1 parent bc90f95 commit a3edeb5
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 2 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
@@ -1,3 +1,7 @@
Wed Aug 9 13:24:25 2000 WATANABE Hirofumi <eban@os.rim.or.jp>

* win32/win32.[ch]: emulate rename(2).

Tue Aug 8 14:01:46 2000 WATANABE Hirofumi <eban@os.rim.or.jp>

* ext/tcltklib/tcltklib.c: support --enable-tcltk_stubs
Expand Down
4 changes: 2 additions & 2 deletions version.h
@@ -1,4 +1,4 @@
#define RUBY_VERSION "1.5.5"
#define RUBY_RELEASE_DATE "2000-08-08"
#define RUBY_RELEASE_DATE "2000-08-09"
#define RUBY_VERSION_CODE 155
#define RUBY_RELEASE_CODE 20000808
#define RUBY_RELEASE_CODE 20000809
48 changes: 48 additions & 0 deletions win32/win32.c
Expand Up @@ -2432,3 +2432,51 @@ win32_getenv(const char *name)

return curitem;
}

int
myrename(const char *oldpath, const char *newpath)
{
int res = 0;
int oldatts;
int newatts;

oldatts = GetFileAttributes(oldpath);
newatts = GetFileAttributes(newpath);

if (oldatts == -1) {
printf("file to move doesn't exist");
return -1;
}

if (newatts != -1 && newatts & FILE_ATTRIBUTE_READONLY)
SetFileAttributesA(newpath, newatts & ~ FILE_ATTRIBUTE_READONLY);

if (!MoveFile(oldpath, newpath))
res = -1;

if (res == 0 || (GetLastError() != ERROR_ALREADY_EXISTS
&& GetLastError() != ERROR_FILE_EXISTS))
goto done;

if (IsWinNT()) {
if (MoveFileEx(oldpath, newpath, MOVEFILE_REPLACE_EXISTING))
res = 0;
} else {
for (;;) {
if (!DeleteFile(newpath) && GetLastError() != ERROR_FILE_NOT_FOUND)
break;
else if (MoveFile(oldpath, newpath)) {
res = 0;
break;
}
}
}

done:
if (res)
errno = GetLastError();
else
SetFileAttributes(newpath, oldatts);

return res;
}
6 changes: 6 additions & 0 deletions win32/win32.h
Expand Up @@ -207,6 +207,7 @@ extern struct protoent * mygetprotobynumber(int);
extern struct servent * mygetservbyname(char *, char *);
extern struct servent * mygetservbyport(int, char *);
extern char *win32_getenv(const char *);
extern int myrename(const char *, const char *);

extern int chown(const char *, int, int);
extern int link(char *, char *);
Expand Down Expand Up @@ -408,4 +409,9 @@ extern char *mystrerror(int);
#endif
#define getenv win32_getenv

#ifdef rename
#undef rename
#endif
#define rename myrename

#endif

0 comments on commit a3edeb5

Please sign in to comment.