win32: Deprecate file CP version functions
This commit is contained in:
parent
95862ae440
commit
37987d9994
Notes:
git
2020-12-20 18:34:27 +09:00
@ -68,7 +68,6 @@
|
||||
#endif
|
||||
|
||||
#include "ruby/internal/dllexport.h"
|
||||
#include "ruby/internal/dosish.h"
|
||||
#include "ruby/internal/xmalloc.h"
|
||||
#include "ruby/backward/2/assume.h"
|
||||
#include "ruby/backward/2/attributes.h"
|
||||
@ -77,6 +76,7 @@
|
||||
#include "ruby/backward/2/long_long.h"
|
||||
#include "ruby/backward/2/stdalign.h"
|
||||
#include "ruby/backward/2/stdarg.h"
|
||||
#include "ruby/internal/dosish.h"
|
||||
#include "ruby/missing.h"
|
||||
|
||||
#define RUBY
|
||||
|
@ -286,11 +286,8 @@ extern struct servent *WSAAPI rb_w32_getservbyport(int, const char *);
|
||||
extern int socketpair(int, int, int, int *);
|
||||
extern int getifaddrs(struct ifaddrs **);
|
||||
extern void freeifaddrs(struct ifaddrs *);
|
||||
extern char * rb_w32_getcwd(char *, int);
|
||||
extern char * rb_w32_ugetcwd(char *, int);
|
||||
extern char * rb_w32_ugetenv(const char *);
|
||||
extern char * rb_w32_getenv(const char *);
|
||||
extern int rb_w32_rename(const char *, const char *);
|
||||
extern int rb_w32_urename(const char *, const char *);
|
||||
extern char **rb_w32_get_environ(void);
|
||||
extern void rb_w32_free_environ(char **);
|
||||
@ -299,22 +296,15 @@ extern const char *WSAAPI rb_w32_inet_ntop(int,const void *,char *,size_t);
|
||||
extern int WSAAPI rb_w32_inet_pton(int,const char *,void *);
|
||||
extern DWORD rb_w32_osver(void);
|
||||
|
||||
extern int chown(const char *, int, int);
|
||||
extern int rb_w32_uchown(const char *, int, int);
|
||||
extern int link(const char *, const char *);
|
||||
extern int rb_w32_ulink(const char *, const char *);
|
||||
extern ssize_t readlink(const char *, char *, size_t);
|
||||
extern ssize_t rb_w32_ureadlink(const char *, char *, size_t);
|
||||
extern ssize_t rb_w32_wreadlink(const WCHAR *, WCHAR *, size_t);
|
||||
extern int symlink(const char *src, const char *link);
|
||||
extern int rb_w32_usymlink(const char *src, const char *link);
|
||||
extern int gettimeofday(struct timeval *, struct timezone *);
|
||||
extern int clock_gettime(clockid_t, struct timespec *);
|
||||
extern int clock_getres(clockid_t, struct timespec *);
|
||||
extern rb_pid_t waitpid (rb_pid_t, int *, int);
|
||||
extern rb_pid_t rb_w32_spawn(int, const char *, const char*);
|
||||
extern rb_pid_t rb_w32_aspawn(int, const char *, char *const *);
|
||||
extern rb_pid_t rb_w32_aspawn_flags(int, const char *, char *const *, DWORD);
|
||||
extern rb_pid_t rb_w32_uspawn(int, const char *, const char*);
|
||||
extern rb_pid_t rb_w32_uaspawn(int, const char *, char *const *);
|
||||
extern rb_pid_t rb_w32_uaspawn_flags(int, const char *, char *const *, DWORD);
|
||||
@ -325,18 +315,12 @@ extern rb_pid_t rb_w32_getpid(void);
|
||||
extern rb_pid_t rb_w32_getppid(void);
|
||||
extern int rb_w32_isatty(int);
|
||||
extern int rb_w32_uchdir(const char *);
|
||||
extern int rb_w32_mkdir(const char *, int);
|
||||
extern int rb_w32_umkdir(const char *, int);
|
||||
extern int rb_w32_rmdir(const char *);
|
||||
extern int rb_w32_urmdir(const char *);
|
||||
extern int rb_w32_unlink(const char *);
|
||||
extern int rb_w32_uunlink(const char *);
|
||||
extern int rb_w32_uchmod(const char *, int);
|
||||
extern int rb_w32_stati128(const char *, struct stati128 *);
|
||||
extern int rb_w32_ustati128(const char *, struct stati128 *);
|
||||
extern int rb_w32_lstati128(const char *, struct stati128 *);
|
||||
extern int rb_w32_ulstati128(const char *, struct stati128 *);
|
||||
extern int rb_w32_access(const char *, int);
|
||||
extern int rb_w32_uaccess(const char *, int);
|
||||
extern char rb_w32_fd_is_text(int);
|
||||
extern int rb_w32_fstati128(int, struct stati128 *);
|
||||
@ -732,7 +716,6 @@ struct tm *localtime_r(const time_t *, struct tm *);
|
||||
|
||||
/* thread stuff */
|
||||
int rb_w32_sleep(unsigned long msec);
|
||||
int rb_w32_open(const char *, int, ...);
|
||||
int rb_w32_uopen(const char *, int, ...);
|
||||
int rb_w32_wopen(const WCHAR *, int, ...);
|
||||
int rb_w32_close(int);
|
||||
@ -741,11 +724,8 @@ int rb_w32_pipe(int[2]);
|
||||
ssize_t rb_w32_read(int, void *, size_t);
|
||||
ssize_t rb_w32_write(int, const void *, size_t);
|
||||
off_t rb_w32_lseek(int, off_t, int);
|
||||
int rb_w32_utime(const char *, const struct utimbuf *);
|
||||
int rb_w32_uutime(const char *, const struct utimbuf *);
|
||||
int rb_w32_utimes(const char *, const struct timeval *);
|
||||
int rb_w32_uutimes(const char *, const struct timeval *);
|
||||
int rb_w32_utimensat(int /* must be AT_FDCWD */, const char *, const struct timespec *, int /* must be 0 */);
|
||||
int rb_w32_uutimensat(int /* must be AT_FDCWD */, const char *, const struct timespec *, int /* must be 0 */);
|
||||
long rb_w32_write_console(uintptr_t, int); /* use uintptr_t instead of VALUE because it's not defined yet here */
|
||||
int WINAPI rb_w32_Sleep(unsigned long msec);
|
||||
@ -756,6 +736,27 @@ int rb_w32_unwrap_io_handle(int);
|
||||
WCHAR *rb_w32_mbstr_to_wstr(UINT, const char *, int, long *);
|
||||
char *rb_w32_wstr_to_mbstr(UINT, const WCHAR *, int, long *);
|
||||
|
||||
DEPRECATED_BY(rb_w32_ugetcwd, char *rb_w32_getcwd(char *, int));
|
||||
DEPRECATED_BY(rb_w32_ugetenv, char *rb_w32_getenv(const char *));
|
||||
DEPRECATED_BY(rb_w32_urename, int rb_w32_rename(const char *, const char *));
|
||||
DEPRECATED_BY(rb_w32_uopen, int rb_w32_open(const char *, int, ...));
|
||||
DEPRECATED_BY(rb_w32_uchown, int chown(const char *, int, int));
|
||||
DEPRECATED_BY(rb_w32_ulink, int link(const char *, const char *));
|
||||
DEPRECATED_BY(rb_w32_ureadlink, ssize_t readlink(const char *, char *, size_t));
|
||||
DEPRECATED_BY(rb_w32_usymlink, int symlink(const char *src, const char *link));
|
||||
DEPRECATED_BY(rb_w32_umkdir, int rb_w32_mkdir(const char *, int));
|
||||
DEPRECATED_BY(rb_w32_urmdir, int rb_w32_rmdir(const char *));
|
||||
DEPRECATED_BY(rb_w32_uunlink, int rb_w32_unlink(const char *));
|
||||
DEPRECATED_BY(rb_w32_uutime, int rb_w32_utime(const char *, const struct utimbuf *));
|
||||
DEPRECATED_BY(rb_w32_uutimes, int rb_w32_utimes(const char *, const struct timeval *));
|
||||
DEPRECATED_BY(rb_w32_uutimensat, int rb_w32_utimensat(int, const char *, const struct timespec *, int));
|
||||
DEPRECATED_BY(rb_w32_ustati128, int rb_w32_stati128(const char *, struct stati128 *));
|
||||
DEPRECATED_BY(rb_w32_ulstati128, int rb_w32_lstati128(const char *, struct stati128 *));
|
||||
DEPRECATED_BY(rb_w32_uaccess, int rb_w32_access(const char *, int));
|
||||
DEPRECATED_BY(rb_w32_uspawn, rb_pid_t rb_w32_spawn(int, const char *, const char*));
|
||||
DEPRECATED_BY(rb_w32_uaspawn, rb_pid_t rb_w32_aspawn(int, const char *, char *const *));
|
||||
DEPRECATED_BY(rb_w32_uaspawn_flags, rb_pid_t rb_w32_aspawn_flags(int, const char *, char *const *, DWORD));
|
||||
|
||||
/*
|
||||
== ***CAUTION***
|
||||
Since this function is very dangerous, ((*NEVER*))
|
||||
|
@ -1569,7 +1569,7 @@ rb_w32_uaspawn_flags(int mode, const char *prog, char *const *argv, DWORD flags)
|
||||
rb_pid_t
|
||||
rb_w32_aspawn(int mode, const char *prog, char *const *argv)
|
||||
{
|
||||
return rb_w32_aspawn_flags(mode, prog, argv, 0);
|
||||
return w32_aspawn_flags(mode, prog, argv, 0, filecp());
|
||||
}
|
||||
|
||||
/* License: Ruby's */
|
||||
@ -5703,7 +5703,7 @@ rb_w32_stat(const char *path, struct stat *st)
|
||||
{
|
||||
struct stati128 tmp;
|
||||
|
||||
if (rb_w32_stati128(path, &tmp)) return -1;
|
||||
if (w32_stati128(path, &tmp, filecp(), FALSE)) return -1;
|
||||
COPY_STAT(tmp, *st, (_off_t));
|
||||
return 0;
|
||||
}
|
||||
@ -5820,11 +5820,11 @@ rb_w32_lseek(int fd, off_t ofs, int whence)
|
||||
}
|
||||
|
||||
/* License: Ruby's */
|
||||
int
|
||||
rb_w32_access(const char *path, int mode)
|
||||
static int
|
||||
w32_access(const char *path, int mode, UINT cp)
|
||||
{
|
||||
struct stati128 stat;
|
||||
if (rb_w32_stati128(path, &stat) != 0)
|
||||
if (w32_stati128(path, &stat, cp, FALSE) != 0)
|
||||
return -1;
|
||||
mode <<= 6;
|
||||
if ((stat.st_mode & mode) != mode) {
|
||||
@ -5834,19 +5834,18 @@ rb_w32_access(const char *path, int mode)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* License: Ruby's */
|
||||
int
|
||||
rb_w32_access(const char *path, int mode)
|
||||
{
|
||||
return w32_access(path, mode, filecp());
|
||||
}
|
||||
|
||||
/* License: Ruby's */
|
||||
int
|
||||
rb_w32_uaccess(const char *path, int mode)
|
||||
{
|
||||
struct stati128 stat;
|
||||
if (rb_w32_ustati128(path, &stat) != 0)
|
||||
return -1;
|
||||
mode <<= 6;
|
||||
if ((stat.st_mode & mode) != mode) {
|
||||
errno = EACCES;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
return w32_access(path, mode, CP_UTF8);
|
||||
}
|
||||
|
||||
/* License: Ruby's */
|
||||
@ -7385,6 +7384,20 @@ wutimensat(int dirfd, const WCHAR *path, const struct timespec *times, int flags
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* License: Ruby's */
|
||||
static int
|
||||
w32_utimensat(int dirfd, const char *path, const struct timespec *times, int flags, UINT cp)
|
||||
{
|
||||
WCHAR *wpath = mbstr_to_wstr(filecp(), path, -1, NULL);
|
||||
int ret = -1;
|
||||
|
||||
if (wpath) {
|
||||
ret = wutimensat(dirfd, wpath, times, flags);
|
||||
free(wpath);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* License: Ruby's */
|
||||
int
|
||||
rb_w32_uutime(const char *path, const struct utimbuf *times)
|
||||
@ -7395,7 +7408,7 @@ rb_w32_uutime(const char *path, const struct utimbuf *times)
|
||||
ts[0].tv_nsec = 0;
|
||||
ts[1].tv_sec = times->modtime;
|
||||
ts[1].tv_nsec = 0;
|
||||
return rb_w32_uutimensat(AT_FDCWD, path, ts, 0);
|
||||
return w32_utimensat(AT_FDCWD, path, ts, 0, CP_UTF8);
|
||||
}
|
||||
|
||||
/* License: Ruby's */
|
||||
@ -7408,7 +7421,7 @@ rb_w32_utime(const char *path, const struct utimbuf *times)
|
||||
ts[0].tv_nsec = 0;
|
||||
ts[1].tv_sec = times->modtime;
|
||||
ts[1].tv_nsec = 0;
|
||||
return rb_w32_utimensat(AT_FDCWD, path, ts, 0);
|
||||
return w32_utimensat(AT_FDCWD, path, ts, 0, filecp());
|
||||
}
|
||||
|
||||
/* License: Ruby's */
|
||||
@ -7421,7 +7434,7 @@ rb_w32_uutimes(const char *path, const struct timeval *times)
|
||||
ts[0].tv_nsec = times[0].tv_usec * 1000;
|
||||
ts[1].tv_sec = times[1].tv_sec;
|
||||
ts[1].tv_nsec = times[1].tv_usec * 1000;
|
||||
return rb_w32_uutimensat(AT_FDCWD, path, ts, 0);
|
||||
return w32_utimensat(AT_FDCWD, path, ts, 0, CP_UTF8);
|
||||
}
|
||||
|
||||
/* License: Ruby's */
|
||||
@ -7434,35 +7447,21 @@ rb_w32_utimes(const char *path, const struct timeval *times)
|
||||
ts[0].tv_nsec = times[0].tv_usec * 1000;
|
||||
ts[1].tv_sec = times[1].tv_sec;
|
||||
ts[1].tv_nsec = times[1].tv_usec * 1000;
|
||||
return rb_w32_utimensat(AT_FDCWD, path, ts, 0);
|
||||
return w32_utimensat(AT_FDCWD, path, ts, 0, filecp());
|
||||
}
|
||||
|
||||
/* License: Ruby's */
|
||||
int
|
||||
rb_w32_uutimensat(int dirfd, const char *path, const struct timespec *times, int flags)
|
||||
{
|
||||
WCHAR *wpath;
|
||||
int ret;
|
||||
|
||||
if (!(wpath = utf8_to_wstr(path, NULL)))
|
||||
return -1;
|
||||
ret = wutimensat(dirfd, wpath, times, flags);
|
||||
free(wpath);
|
||||
return ret;
|
||||
return w32_utimensat(dirfd, path, times, flags, CP_UTF8);
|
||||
}
|
||||
|
||||
/* License: Ruby's */
|
||||
int
|
||||
rb_w32_utimensat(int dirfd, const char *path, const struct timespec *times, int flags)
|
||||
{
|
||||
WCHAR *wpath;
|
||||
int ret;
|
||||
|
||||
if (!(wpath = filecp_to_wstr(path, NULL)))
|
||||
return -1;
|
||||
ret = wutimensat(dirfd, wpath, times, flags);
|
||||
free(wpath);
|
||||
return ret;
|
||||
return w32_utimensat(dirfd, path, times, flags, filecp());
|
||||
}
|
||||
|
||||
/* License: Ruby's */
|
||||
|
Loading…
x
Reference in New Issue
Block a user