@@ -73,24 +73,24 @@ int flock(int, int);
73
73
/* define system APIs */
74
74
#ifdef _WIN32
75
75
#define STAT (p , s ) rb_w32_wstati64((WCHAR *)(p), s)
76
- #define LSTAT (p , s ) rb_w32_wstati64((WCHAR *)(p), s)
77
- #define ACCESS (p , m ) _waccess((WCHAR *)(p), m)
78
- #define CHMOD (p , m ) _wchmod((WCHAR *)(p), m)
79
- #define CHOWN (p , o , g ) rb_w32_wchown((WCHAR *)(p), o, g)
80
- #define UTIME (p , t ) rb_w32_wutime((WCHAR *)(p), t)
81
- #define LINK (f , t ) rb_w32_wlink((WCHAR *)(f), (WCHAR *)(t))
82
- #define UNLINK (p ) rb_w32_wunlink((WCHAR *)(p))
83
- #define RENAME (f , t ) _wrename((WCHAR *)(f), (WCHAR *)(t))
76
+ #undef lstat
77
+ #define lstat (p , s ) rb_w32_wstati64((WCHAR *)(p), s)
78
+ #undef access
79
+ #define access (p , m ) _waccess((WCHAR *)(p), m)
80
+ #undef chmod
81
+ #define chmod (p , m ) _wchmod((WCHAR *)(p), m)
82
+ #undef chown
83
+ #define chown (p , o , g ) rb_w32_wchown((WCHAR *)(p), o, g)
84
+ #undef utime
85
+ #define utime (p , t ) rb_w32_wutime((WCHAR *)(p), t)
86
+ #undef link
87
+ #define link (f , t ) rb_w32_wlink((WCHAR *)(f), (WCHAR *)(t))
88
+ #undef unlink
89
+ #define unlink (p ) rb_w32_wunlink((WCHAR *)(p))
90
+ #undef rename
91
+ #define rename (f , t ) _wrename((WCHAR *)(f), (WCHAR *)(t))
84
92
#else
85
93
#define STAT (p , s ) stat(p, s)
86
- #define LSTAT (p , s ) lstat(p, s)
87
- #define ACCESS (p , m ) access(p, m)
88
- #define CHMOD (p , m ) chmod(p, m)
89
- #define CHOWN (p , o , g ) chown(p, o, g)
90
- #define UTIME (p , t ) utime(p, t)
91
- #define LINK (f , t ) link(f, t)
92
- #define UNLINK (p ) unlink(p)
93
- #define RENAME (f , t ) rename(f, t)
94
94
#endif
95
95
96
96
#ifdef __BEOS__ /* should not change ID if -1 */
@@ -99,7 +99,7 @@ be_chown(const char *path, uid_t owner, gid_t group)
99
99
{
100
100
if (owner == -1 || group == -1 ) {
101
101
struct stat st ;
102
- if (stat (path , & st ) < 0 ) return -1 ;
102
+ if (STAT (path , & st ) < 0 ) return -1 ;
103
103
if (owner == -1 ) owner = st .st_uid ;
104
104
if (group == -1 ) group = st .st_gid ;
105
105
}
@@ -956,7 +956,7 @@ rb_file_lstat(VALUE obj)
956
956
GetOpenFile (obj , fptr );
957
957
if (NIL_P (fptr -> pathv )) return Qnil ;
958
958
path = rb_str_conv_for_path (fptr -> pathv );
959
- if (LSTAT (RSTRING_PTR (path ), & st ) == -1 ) {
959
+ if (lstat (RSTRING_PTR (path ), & st ) == -1 ) {
960
960
rb_sys_fail_path (fptr -> pathv );
961
961
}
962
962
return stat_new (& st );
@@ -1039,15 +1039,15 @@ eaccess(const char *path, int mode)
1039
1039
1040
1040
return -1 ;
1041
1041
#else
1042
- return ACCESS (path , mode );
1042
+ return access (path , mode );
1043
1043
#endif
1044
1044
}
1045
1045
#endif
1046
1046
1047
1047
static inline int
1048
1048
access_internal (const char * path , int mode )
1049
1049
{
1050
- return ACCESS (path , mode );
1050
+ return access (path , mode );
1051
1051
}
1052
1052
1053
1053
@@ -1559,7 +1559,7 @@ check3rdbyte(VALUE fname, int mode)
1559
1559
rb_secure (2 );
1560
1560
FilePathValue (fname );
1561
1561
fname = rb_str_conv_for_path (fname );
1562
- if (stat (RSTRING_PTR (fname ), & st ) < 0 ) return Qfalse ;
1562
+ if (STAT (RSTRING_PTR (fname ), & st ) < 0 ) return Qfalse ;
1563
1563
if (st .st_mode & mode ) return Qtrue ;
1564
1564
return Qfalse ;
1565
1565
}
@@ -1765,7 +1765,7 @@ rb_file_s_ftype(VALUE klass, VALUE fname)
1765
1765
rb_secure (2 );
1766
1766
FilePathValue (fname );
1767
1767
fname = rb_str_conv_for_path (fname );
1768
- if (LSTAT (RSTRING_PTR (fname ), & st ) == -1 )
1768
+ if (lstat (RSTRING_PTR (fname ), & st ) == -1 )
1769
1769
rb_sys_fail (RSTRING_PTR (fname ));
1770
1770
1771
1771
return rb_file_ftype (& st );
@@ -1939,7 +1939,7 @@ rb_file_size(VALUE obj)
1939
1939
static void
1940
1940
chmod_internal (const char * path , void * mode )
1941
1941
{
1942
- if (CHMOD (path , * (int * )mode ) < 0 )
1942
+ if (chmod (path , * (int * )mode ) < 0 )
1943
1943
rb_sys_fail (path );
1944
1944
}
1945
1945
@@ -2004,7 +2004,7 @@ rb_file_chmod(VALUE obj, VALUE vmode)
2004
2004
#else
2005
2005
if (NIL_P (fptr -> pathv )) return Qnil ;
2006
2006
path = rb_str_conv_for_path (fptr -> pathv );
2007
- if (CHMOD (RSTRING_PTR (path ), mode ) == -1 )
2007
+ if (chmod (RSTRING_PTR (path ), mode ) == -1 )
2008
2008
rb_sys_fail_path (fptr -> pathv );
2009
2009
#endif
2010
2010
@@ -2132,7 +2132,7 @@ rb_file_chown(VALUE obj, VALUE owner, VALUE group)
2132
2132
#ifndef HAVE_FCHOWN
2133
2133
if (NIL_P (fptr -> pathv )) return Qnil ;
2134
2134
path = rb_str_conv_for_path (fptr -> pathv );
2135
- if (CHOWN (RSTRING_PTR (path ), o , g ) == -1 )
2135
+ if (chown (RSTRING_PTR (path ), o , g ) == -1 )
2136
2136
rb_sys_fail_path (fptr -> pathv );
2137
2137
#else
2138
2138
if (fchown (fptr -> fd , o , g ) == -1 )
@@ -2292,7 +2292,7 @@ utime_internal(const char *path, void *arg)
2292
2292
utbuf .modtime = tsp [1 ].tv_sec ;
2293
2293
utp = & utbuf ;
2294
2294
}
2295
- if (UTIME (path , utp ) < 0 )
2295
+ if (utime (path , utp ) < 0 )
2296
2296
utime_failed (path , tsp , v -> atime , v -> mtime );
2297
2297
}
2298
2298
@@ -2471,7 +2471,7 @@ rb_file_s_readlink(VALUE klass, VALUE path)
2471
2471
static void
2472
2472
unlink_internal (const char * path , void * arg )
2473
2473
{
2474
- if (UNLINK (path ) < 0 )
2474
+ if (unlink (path ) < 0 )
2475
2475
rb_sys_fail (path );
2476
2476
}
2477
2477
@@ -2521,16 +2521,16 @@ rb_file_s_rename(VALUE klass, VALUE from, VALUE to)
2521
2521
#if defined __CYGWIN__
2522
2522
errno = 0 ;
2523
2523
#endif
2524
- if (RENAME (src , dst ) < 0 ) {
2524
+ if (rename (src , dst ) < 0 ) {
2525
2525
#if defined DOSISH
2526
2526
switch (errno ) {
2527
2527
case EEXIST :
2528
2528
#if defined (__EMX__ )
2529
2529
case EACCES :
2530
2530
#endif
2531
- if (CHMOD (dst , 0666 ) == 0 &&
2532
- UNLINK (dst ) == 0 &&
2533
- RENAME (src , dst ) == 0 )
2531
+ if (chmod (dst , 0666 ) == 0 &&
2532
+ unlink (dst ) == 0 &&
2533
+ rename (src , dst ) == 0 )
2534
2534
return INT2FIX (0 );
2535
2535
}
2536
2536
#endif
@@ -4637,7 +4637,7 @@ path_check_0(VALUE path, int execpath)
4637
4637
#ifndef S_IWOTH
4638
4638
# define S_IWOTH 002
4639
4639
#endif
4640
- if (stat (p0 , & st ) == 0 && S_ISDIR (st .st_mode ) && (st .st_mode & S_IWOTH )
4640
+ if (STAT (p0 , & st ) == 0 && S_ISDIR (st .st_mode ) && (st .st_mode & S_IWOTH )
4641
4641
#ifdef S_ISVTX
4642
4642
&& !(p && execpath && (st .st_mode & S_ISVTX ))
4643
4643
#endif
0 commit comments