19 #include <sys/cygwin.h>
23 #include <CoreFoundation/CFString.h>
36 #ifdef HAVE_SYS_FILE_H
37 # include <sys/file.h>
42 #ifdef HAVE_SYS_PARAM_H
43 # include <sys/param.h>
46 # define MAXPATHLEN 1024
55 #elif defined HAVE_SYS_UTIME_H
56 #include <sys/utime.h>
63 #include <sys/types.h>
66 #if defined(__native_client__) && defined(NACL_NEWLIB)
73 #ifdef HAVE_SYS_MKDEV_H
74 #include <sys/mkdev.h>
77 #if defined(HAVE_FCNTL_H)
81 #if defined(HAVE_SYS_TIME_H)
85 #if !defined HAVE_LSTAT && !defined lstat
91 #define STAT(p, s) rb_w32_ustati64((p), (s))
93 #define lstat(p, s) rb_w32_ustati64((p), (s))
95 #define access(p, m) rb_w32_uaccess((p), (m))
97 #define chmod(p, m) rb_w32_uchmod((p), (m))
99 #define chown(p, o, g) rb_w32_uchown((p), (o), (g))
101 #define utime(p, t) rb_w32_uutime((p), (t))
103 #define link(f, t) rb_w32_ulink((f), (t))
105 #define unlink(p) rb_w32_uunlink(p)
107 #define rename(f, t) rb_w32_urename((f), (t))
109 #define STAT(p, s) stat((p), (s))
112 #if defined(__BEOS__) || defined(__HAIKU__)
114 be_chown(
const char *
path, uid_t owner, gid_t group)
116 if (owner == (uid_t)-1 || group == (gid_t)-1) {
118 if (
STAT(path, &st) < 0)
return -1;
119 if (owner == (uid_t)-1) owner = st.st_uid;
120 if (group == (gid_t)-1) group = st.st_gid;
122 return chown(path, owner, group);
124 #define chown be_chown
126 be_fchown(
int fd, uid_t owner, gid_t group)
128 if (owner == (uid_t)-1 || group == (gid_t)-1) {
130 if (
fstat(fd, &st) < 0)
return -1;
131 if (owner == (uid_t)-1) owner = st.st_uid;
132 if (group == (gid_t)-1) group = st.st_gid;
134 return fchown(fd, owner, group);
136 #define fchown be_fchown
143 #define insecure_obj_p(obj, level) ((level) >= 4 || ((level) > 0 && OBJ_TAINTED(obj)))
242 #elif defined __APPLE__
250 rb_str_normalize_ospath0(
const char *ptr,
long len)
255 CFStringRef s = CFStringCreateWithBytesNoCopy(kCFAllocatorDefault,
256 (
const UInt8 *)ptr, len,
257 kCFStringEncodingUTF8,
FALSE,
259 CFMutableStringRef m = CFStringCreateMutableCopy(kCFAllocatorDefault, len, s);
261 CFStringNormalize(m, kCFStringNormalizationFormC);
262 all = CFRangeMake(0, CFStringGetLength(m));
263 CFStringGetBytes(m, all, kCFStringEncodingUTF8,
'?',
FALSE,
NULL, 0, &buflen);
265 CFStringGetBytes(m, all, kCFStringEncodingUTF8,
'?',
FALSE, (UInt8 *)
RSTRING_PTR(str),
274 rb_str_normalize_ospath(
const char *ptr,
long len)
277 const char *e = ptr + len;
294 if ((0x2000 <= c && c <= 0x2FFF) || (0xF900 <= c && c <= 0xFAFF) ||
295 (0x2F800 <= c && c <= 0x2FAFF)) {
326 (*func)(s, path, arg);
359 return p ?
sizeof(
struct stat) : 0;
371 struct stat *nst = 0;
429 #define ST2UINT(val) ((val) & ~(~1UL << (sizeof(val) * CHAR_BIT - 1)))
432 # define NUM2DEVT(v) NUM2UINT(v)
435 # define DEVT2NUM(v) UINT2NUM(v)
437 #ifndef PRI_DEVT_PREFIX
438 # define PRI_DEVT_PREFIX ""
512 #if SIZEOF_STRUCT_STAT_ST_INO > SIZEOF_LONG
513 return ULL2NUM(
get_stat(
self)->st_ino);
603 #ifdef HAVE_STRUCT_STAT_ST_RDEV
624 #if defined(HAVE_STRUCT_STAT_ST_RDEV) && defined(major)
645 #if defined(HAVE_STRUCT_STAT_ST_RDEV) && defined(minor)
681 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
702 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
703 # if SIZEOF_STRUCT_STAT_ST_BLOCKS > SIZEOF_LONG
704 return ULL2NUM(
get_stat(
self)->st_blocks);
718 #if defined(HAVE_STRUCT_STAT_ST_ATIM)
719 ts.
tv_nsec = st->st_atim.tv_nsec;
720 #elif defined(HAVE_STRUCT_STAT_ST_ATIMESPEC)
721 ts.
tv_nsec = st->st_atimespec.tv_nsec;
722 #elif defined(HAVE_STRUCT_STAT_ST_ATIMENSEC)
742 #if defined(HAVE_STRUCT_STAT_ST_MTIM)
743 ts.
tv_nsec = st->st_mtim.tv_nsec;
744 #elif defined(HAVE_STRUCT_STAT_ST_MTIMESPEC)
745 ts.
tv_nsec = st->st_mtimespec.tv_nsec;
746 #elif defined(HAVE_STRUCT_STAT_ST_MTIMENSEC)
766 #if defined(HAVE_STRUCT_STAT_ST_CTIM)
767 ts.
tv_nsec = st->st_ctim.tv_nsec;
768 #elif defined(HAVE_STRUCT_STAT_ST_CTIMESPEC)
769 ts.
tv_nsec = st->st_ctimespec.tv_nsec;
770 #elif defined(HAVE_STRUCT_STAT_ST_CTIMENSEC)
857 static const struct {
886 for (i = 0; i <
sizeof(member)/
sizeof(member[0]); i++) {
894 v = (*member[i].func)(
self);
898 else if (i == 0 || i == 6) {
931 w32_io_info(
VALUE *file, BY_HANDLE_FILE_INFORMATION *st)
942 if (f == (HANDLE)-1)
return INVALID_HANDLE_VALUE;
954 MultiByteToWideChar(CP_UTF8, 0,
RSTRING_PTR(tmp), -1, ptr, len);
955 f = CreateFileW(ptr, 0,
956 FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING,
957 FILE_FLAG_BACKUP_SEMANTICS,
NULL);
959 if (f == INVALID_HANDLE_VALUE)
return f;
962 if (GetFileType(f) == FILE_TYPE_DISK) {
963 ZeroMemory(st,
sizeof(*st));
964 if (GetFileInformationByHandle(f, st))
return ret;
966 if (ret) CloseHandle(ret);
967 return INVALID_HANDLE_VALUE;
1016 if (
fstat(fptr->
fd, &st) == -1) {
1110 gary =
ALLOCV_N(GETGROUPS_T, v, groups);
1111 anum = getgroups(groups, gary);
1112 if (anum != -1 && anum != groups)
1123 while (--anum >= 0) {
1124 if (gary[anum] == gid) {
1137 # define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
1140 #if defined(S_IXGRP) && !defined(_WIN32) && !defined(__CYGWIN__)
1141 #define USE_GETEUID 1
1144 #ifndef HAVE_EACCESS
1156 return access(path, mode);
1158 if (
STAT(path, &st) < 0)
1174 if (st.st_uid == euid)
1179 if ((
int)(st.st_mode & mode) == mode)
return 0;
1183 return access(path, mode);
1218 # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
1242 # define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
1248 if (S_ISFIFO(st.st_mode))
return Qtrue;
1266 # define S_ISLNK(m) _S_ISLNK(m)
1269 # define S_ISLNK(m) (((m) & S_IFMT) == _S_IFLNK)
1272 # define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
1305 # define S_ISSOCK(m) _S_ISSOCK(m)
1308 # define S_ISSOCK(m) (((m) & S_IFMT) == _S_IFSOCK)
1311 # define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
1321 if (S_ISSOCK(st.st_mode))
return Qtrue;
1341 # define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
1343 # define S_ISBLK(m) (0)
1369 # define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
1404 const char *s =
"FileTest#";
1405 if (obj == rb_mFileTest) {
1408 else if (obj == rb_cFile ||
1413 rb_warning(
"%sexists? is a deprecated name, use %sexist? instead", s, s);
1454 # define S_IRUGO (S_IRUSR | S_IRGRP | S_IROTH)
1458 # define S_IWUGO (S_IWUSR | S_IWGRP | S_IWOTH)
1594 # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
1633 if (st.st_size == 0)
return Qtrue;
1653 if (st.st_size == 0)
return Qnil;
1711 #if defined(S_ISUID) || defined(S_ISGID) || defined(S_ISVTX)
1713 check3rdbyte(
VALUE fname,
int mode)
1721 if (st.st_mode & mode)
return Qtrue;
1737 return check3rdbyte(fname, S_ISUID);
1754 return check3rdbyte(fname, S_ISGID);
1771 return check3rdbyte(fname, S_ISVTX);
1800 struct stat st1, st2;
1804 if (st1.st_dev != st2.st_dev)
return Qfalse;
1805 if (st1.st_ino != st2.st_ino)
return Qfalse;
1808 BY_HANDLE_FILE_INFORMATION st1, st2;
1809 HANDLE f1 = 0, f2 = 0;
1814 f1 = w32_io_info(&fname1, &st1);
1815 if (f1 == INVALID_HANDLE_VALUE)
return Qfalse;
1816 f2 = w32_io_info(&fname2, &st2);
1817 if (f1) CloseHandle(f1);
1818 if (f2 == INVALID_HANDLE_VALUE)
return Qfalse;
1819 if (f2) CloseHandle(f2);
1821 if (st1.dwVolumeSerialNumber == st2.dwVolumeSerialNumber &&
1822 st1.nFileIndexHigh == st2.nFileIndexHigh &&
1823 st1.nFileIndexLow == st2.nFileIndexLow)
1825 if (!f1 || !f2)
return Qfalse;
1858 if (
rb_stat(fname, &st) < 0) {
1873 else if (
S_ISDIR(st->st_mode)) {
1876 else if (
S_ISCHR(st->st_mode)) {
1877 t =
"characterSpecial";
1880 else if (
S_ISBLK(st->st_mode)) {
1885 else if (S_ISFIFO(st->st_mode)) {
1890 else if (
S_ISLNK(st->st_mode)) {
1895 else if (S_ISSOCK(st->st_mode)) {
1953 if (
rb_stat(fname, &st) < 0) {
1978 if (
fstat(fptr->
fd, &st) == -1) {
2001 if (
rb_stat(fname, &st) < 0) {
2025 if (
fstat(fptr->
fd, &st) == -1) {
2052 if (
rb_stat(fname, &st) < 0) {
2079 if (
fstat(fptr->
fd, &st) == -1) {
2105 if (
fstat(fptr->
fd, &st) == -1) {
2114 if (chmod(path, *(
int *)mode) < 0)
2174 if (fchmod(fptr->
fd, mode) == -1)
2186 #if defined(HAVE_LCHMOD)
2188 lchmod_internal(
const char *path,
VALUE pathv,
void *mode)
2190 if (lchmod(path, (
int)(
VALUE)mode) < 0)
2215 n =
apply2files(lchmod_internal, rest, (
void *)(
long)mode);
2219 #define rb_file_s_lchmod rb_f_notimplement
2310 if (fchown(fptr->
fd, o, g) == -1)
2317 #if defined(HAVE_LCHOWN)
2319 lchown_internal(
const char *path,
VALUE pathv,
void *arg)
2322 if (lchown(path, args->
owner, args->
group) < 0)
2363 #define rb_file_s_lchown rb_f_notimplement
2371 #if defined DOSISH || defined __CYGWIN__
2377 if (tsp &&
errno == EINVAL) {
2380 if (!
NIL_P(atime)) {
2383 if (!
NIL_P(mtime) && mtime != atime && !
rb_equal(atime, mtime)) {
2386 if (
NIL_P(a)) e[0] = m;
2406 #define utime_failed(path, tsp, atime, mtime) rb_sys_fail_path(path)
2409 #if defined(HAVE_UTIMES)
2418 #ifdef HAVE_UTIMENSAT
2419 static int try_utimensat = 1;
2421 if (try_utimensat) {
2422 if (utimensat(AT_FDCWD, path, tsp, 0) < 0) {
2423 if (
errno == ENOSYS) {
2436 tvbuf[0].
tv_usec = (int)(tsp[0].tv_nsec / 1000);
2438 tvbuf[1].
tv_usec = (int)(tsp[1].tv_nsec / 1000);
2441 if (
utimes(path, tvp) < 0)
2447 #if !defined HAVE_UTIME_H && !defined HAVE_SYS_UTIME_H
2465 if (
utime(path, utp) < 0)
2508 const int max_pathlen = MAX_PATH;
2549 #define rb_file_s_link rb_f_notimplement
2580 #define rb_file_s_symlink rb_f_notimplement
2583 #ifdef HAVE_READLINK
2600 return rb_readlink(path);
2604 rb_readlink(
VALUE path)
2616 || (rv < 0 &&
errno == ERANGE)
2632 #define rb_file_s_readlink rb_f_notimplement
2638 if (unlink(path) < 0)
2675 const char *src, *dst;
2685 #if defined __CYGWIN__
2688 if (rename(src, dst) < 0) {
2692 #if defined (__EMX__)
2695 if (chmod(dst, 0666) == 0 &&
2697 rename(src, dst) == 0)
2732 else if (argc == 1) {
2744 #if defined __CYGWIN__ || defined DOSISH
2746 #define DOSISH_DRIVE_LETTER
2747 #define FILE_ALT_SEPARATOR '\\'
2749 #ifdef FILE_ALT_SEPARATOR
2750 #define isdirsep(x) ((x) == '/' || (x) == FILE_ALT_SEPARATOR)
2751 static const char file_alt_separator[] = {FILE_ALT_SEPARATOR,
'\0'};
2753 #define isdirsep(x) ((x) == '/')
2757 #if defined _WIN32 || defined __CYGWIN__
2765 #define istrailinggarbage(x) ((x) == '.' || (x) == ' ')
2767 #define istrailinggarbage(x) 0
2770 #define Next(p, e, enc) ((p) + rb_enc_mbclen((p), (e), (enc)))
2771 #define Inc(p, e, enc) ((p) = Next((p), (e), (enc)))
2773 #if defined(DOSISH_UNC)
2774 #define has_unc(buf) (isdirsep((buf)[0]) && isdirsep((buf)[1]))
2776 #define has_unc(buf) 0
2779 #ifdef DOSISH_DRIVE_LETTER
2781 has_drive_letter(
const char *
buf)
2783 if (
ISALPHA(buf[0]) && buf[1] ==
':') {
2793 getcwdofdrv(
int drv)
2796 char *drvcwd, *oldcwd;
2807 if (chdir(drive) == 0) {
2821 not_same_drive(
VALUE path,
int drive)
2825 if (has_drive_letter(p)) {
2834 static inline char *
2837 #ifdef DOSISH_DRIVE_LETTER
2838 if (path + 2 <= end && has_drive_letter(path)) path += 2;
2840 while (path < end &&
isdirsep(*path)) path++;
2841 return (
char *)path;
2844 #define nextdirsep rb_enc_path_next
2854 #if defined(DOSISH_UNC) || defined(DOSISH_DRIVE_LETTER)
2855 #define skipprefix rb_enc_path_skip_prefix
2857 #define skipprefix(path, end, enc) (path)
2862 #if defined(DOSISH_UNC) || defined(DOSISH_DRIVE_LETTER)
2866 while (path < end &&
isdirsep(*path)) path++;
2869 return (
char *)path;
2872 #ifdef DOSISH_DRIVE_LETTER
2873 if (has_drive_letter(path))
2874 return (
char *)(path + 2);
2877 return (
char *)path;
2880 static inline char *
2883 #if defined(DOSISH_UNC) || defined(DOSISH_DRIVE_LETTER)
2892 #define strrdirsep rb_enc_path_last_separator
2897 while (path < end) {
2899 const char *tmp = path++;
2900 while (path < end &&
isdirsep(*path)) path++;
2901 if (path >= end)
break;
2905 Inc(path, end, enc);
2914 while (path < end) {
2916 const char *
last = path++;
2917 while (path < end &&
isdirsep(*path)) path++;
2918 if (path >= end)
return (
char *)
last;
2921 Inc(path, end, enc);
2924 return (
char *)path;
2930 if (path < end &&
isdirsep(*path)) path++;
2936 ntfs_tail(
const char *path,
const char *end,
rb_encoding *enc)
2938 while (path < end && *path ==
'.') path++;
2939 while (path < end && *path !=
':') {
2941 const char *
last = path++;
2943 if (path >= end || *path ==
':')
return (
char *)
last;
2946 const char *last = path++;
2947 while (path < end &&
isdirsep(*path)) path++;
2948 if (path >= end)
return (
char *)
last;
2949 if (*path ==
':') path++;
2952 Inc(path, end, enc);
2955 return (
char *)path;
2959 #define BUFCHECK(cond) do {\
2962 do {buflen *= 2;} while (cond);\
2963 rb_str_resize(result, buflen);\
2964 buf = RSTRING_PTR(result);\
2966 pend = buf + buflen;\
2970 #define BUFINIT() (\
2971 p = buf = RSTRING_PTR(result),\
2972 buflen = RSTRING_LEN(result),\
2979 #if defined DOSISH || defined __CYGWIN__
2990 #if defined DOSISH || defined __CYGWIN__
2991 for (bend = (p = buf) + dirlen; p < bend;
Inc(p, bend, enc)) {
3004 struct passwd *pwPtr = getpwnam(
RSTRING_PTR(user));
3020 const char *dir =
getenv(
"HOME");
3031 char *
buf, *cwdp = dir;
3035 if (*enc != fsenc) {
3037 if (direnc != fsenc) {
3043 do {buflen *= 2;}
while (dirlen > buflen);
3046 memcpy(buf, cwdp, dirlen);
3050 return buf + dirlen;
3056 const char *s, *b, *fend;
3057 char *
buf, *p, *pend, *root;
3058 size_t buflen, bdiff;
3068 if (s[0] ==
'~' && abs_mode == 0) {
3071 if (
isdirsep(s[1]) || s[1] ==
'\0') {
3082 BUFCHECK(bdiff + userlen >= buflen);
3083 memcpy(p, b, userlen);
3094 (
int)userlen, b, fname);
3103 #ifdef DOSISH_DRIVE_LETTER
3105 else if (has_drive_letter(s)) {
3118 if (!
NIL_P(dname) && !not_same_drive(dname, s[0])) {
3127 char *e =
append_fspath(result, fname, getcwdofdrv(*s), &enc, fsenc);
3142 if (!
NIL_P(dname)) {
3154 #if defined DOSISH || defined __CYGWIN__
3171 memset(buf,
'/', len);
3175 if (p > buf && p[-1] ==
'/')
3198 if (*(s+1) ==
'\0' ||
isdirsep(*(s+1))) {
3217 #if defined DOSISH || defined __CYGWIN__
3242 #if defined DOSISH || defined __CYGWIN__
3246 long rootdiff = root -
buf;
3248 BUFCHECK(bdiff + (s-b+1) >= buflen);
3249 root = buf + rootdiff;
3250 memcpy(++p, b, s-b);
3264 static const char prime[] =
":$DATA";
3265 enum {prime_len =
sizeof(prime) -1};
3267 if (s > b + prime_len &&
strncasecmp(s - prime_len, prime, prime_len) == 0) {
3270 if (*(s - (prime_len+1)) ==
':') {
3273 else if (memchr(b,
':', s - prime_len - b)) {
3280 memcpy(++p, b, s-b);
3284 if (p ==
skiproot(buf, p + !!*p, enc) - 1) p++;
3288 if ((s =
strrdirsep(b = buf, p, enc)) != 0 && !strpbrk(s,
"*?")) {
3293 WIN32_FIND_DATAW wfd;
3296 #ifdef HAVE_CYGWIN_CONV_PATH
3297 char *w32buf =
NULL;
3298 const int flags = CCP_POSIX_TO_WIN_A | CCP_RELATIVE;
3304 int lnk_added = 0, is_symlink = 0;
3310 if (len > 4 &&
STRCASECMP(p + len - 4,
".lnk") != 0) {
3314 path = *buf ? buf :
"/";
3315 #ifdef HAVE_CYGWIN_CONV_PATH
3316 bufsize = cygwin_conv_path(flags, path,
NULL, 0);
3319 if (lnk_added) bufsize += 4;
3321 if (cygwin_conv_path(flags, path, w32buf, bufsize) == 0) {
3327 if (cygwin_conv_to_win32_path(path, w32buf) == 0) {
3331 if (is_symlink && b == w32buf) {
3335 strlcat(w32buf,
".lnk", bufsize);
3351 MultiByteToWideChar(CP_UTF8, 0,
RSTRING_PTR(tmp), -1, wstr, len);
3353 h = FindFirstFileW(wstr, &wfd);
3355 if (h != INVALID_HANDLE_VALUE) {
3358 len = lstrlenW(wfd.cFileName);
3360 if (lnk_added && len > 4 &&
3361 wcscasecmp(wfd.cFileName + len - 4, L
".lnk") == 0) {
3362 wfd.cFileName[len -= 4] = L
'\0';
3369 len = WideCharToMultiByte(CP_UTF8, 0, wfd.cFileName, wlen,
NULL, 0,
NULL,
NULL);
3371 WideCharToMultiByte(CP_UTF8, 0, wfd.cFileName, wlen, p, len + 1,
NULL,
NULL);
3372 if (tmp != result) {
3398 #define EXPAND_PATH_BUFFER() rb_usascii_str_new(0, MAXPATHLEN + 2)
3407 #define expand_path(fname, dname, abs_mode, long_name, result) \
3408 str_shrink(rb_file_expand_path_internal(fname, dname, abs_mode, long_name, result))
3410 #define check_expand_path_args(fname, dname) \
3411 (((fname) = rb_get_path(fname)), \
3412 (void)(NIL_P(dname) ? (dname) : ((dname) = rb_get_path(dname))))
3510 const char *pend = unresolved +
strlen(unresolved);
3514 while (unresolved < pend) {
3515 const char *testname = unresolved;
3517 long testnamelen = unresolved_firstsep - unresolved;
3518 const char *unresolved_nextname = unresolved_firstsep;
3519 while (unresolved_nextname < pend &&
isdirsep(*unresolved_nextname))
3520 unresolved_nextname++;
3521 unresolved = unresolved_nextname;
3522 if (testnamelen == 1 && testname[0] ==
'.') {
3524 else if (testnamelen == 2 && testname[0] ==
'.' && testname[1] ==
'.') {
3526 const char *resolved_str =
RSTRING_PTR(*resolvedp);
3527 const char *resolved_names = resolved_str + *prefixlenp;
3529 long len = lastsep ? lastsep - resolved_names : 0;
3538 #if defined(DOSISH_UNC) || defined(DOSISH_DRIVE_LETTER)
3539 if (*prefixlenp > 1 && *prefixlenp ==
RSTRING_LEN(testpath)) {
3541 const char *last =
rb_enc_left_char_head(prefix, prefix + *prefixlenp - 1, prefix + *prefixlenp, enc);
3547 if (!
NIL_P(checkval)) {
3548 if (checkval ==
ID2SYM(resolving)) {
3560 #ifdef __native_client__
3566 if (
errno == ENOENT) {
3567 if (strict || !last || *unresolved_firstsep)
3569 *resolvedp = testpath;
3576 #ifdef HAVE_READLINK
3580 const char *link_prefix, *link_names;
3581 long link_prefixlen;
3583 link = rb_readlink(testpath);
3586 link_prefixlen = link_names - link_prefix;
3587 if (link_prefixlen > 0) {
3594 *prefixlenp = link_prefixlen;
3596 realpath_rec(prefixlenp, resolvedp, link_names, loopcheck, strict, *unresolved_firstsep ==
'\0');
3605 *resolvedp = testpath;
3612 #ifdef __native_client__
3624 volatile VALUE unresolved_path;
3629 char *path_names =
NULL, *basedir_names =
NULL, *curdir_names =
NULL;
3630 char *ptr, *prefixptr =
NULL, *pend;
3638 if (!
NIL_P(basedir)) {
3645 if (ptr != path_names) {
3646 resolved =
rb_str_subseq(unresolved_path, 0, path_names - ptr);
3650 if (!
NIL_P(basedir)) {
3653 if (ptr != basedir_names) {
3666 pend = prefixptr + prefixlen;
3670 prefixlen = ++ptr - prefixptr;
3673 #ifdef FILE_ALT_SEPARATOR
3674 while (prefixptr < ptr) {
3675 if (*prefixptr == FILE_ALT_SEPARATOR) {
3678 Inc(prefixptr, pend, enc);
3684 realpath_rec(&prefixlen, &resolved, curdir_names, loopcheck, 1, 0);
3686 realpath_rec(&prefixlen, &resolved, basedir_names, loopcheck, 1, 0);
3687 realpath_rec(&prefixlen, &resolved, path_names, loopcheck, strict, 1);
3710 VALUE path, basedir;
3730 VALUE path, basedir;
3740 const char *s, *
last;
3742 if (!e || !l2)
return 0;
3745 if (
rb_enc_ascget(e + len1, e + l2, &len2, enc) ==
'*' && len1 + len2 == l2) {
3746 if (c ==
'.')
return l0;
3756 if (l1 < l2)
return l1;
3760 #if CASEFOLD_FILESYSTEM
3761 #define fncomp strncasecmp
3763 #define fncomp strncmp
3765 if (
fncomp(s, e, l2) == 0) {
3774 const char *p, *q, *e, *end;
3775 #if defined DOSISH_DRIVE_LETTER || defined DOSISH_UNC
3780 end = name + (alllen ? (size_t)*alllen :
strlen(name));
3782 #if defined DOSISH_DRIVE_LETTER || defined DOSISH_UNC
3790 #if defined DOSISH_DRIVE_LETTER || defined DOSISH_UNC
3794 #ifdef DOSISH_DRIVE_LETTER
3795 else if (*p ==
':') {
3815 n = ntfs_tail(p, end, enc) - p;
3819 for (q = p; q - p < n && *q ==
'.'; q++);
3820 for (e = 0; q - p < n;
Inc(q, end, enc)) {
3821 if (*q ==
'.') e = q;
3852 VALUE fname, fext, basename;
3853 const char *
name, *p;
3857 if (
rb_scan_args(argc, argv,
"11", &fname, &fext) == 2) {
3912 const char *
name, *root, *p, *end;
3922 if (root > name + 1 &&
isdirsep(*name))
3923 root =
skipprefix(name = root - 2, end, enc);
3925 if (root > name + 1)
3934 #ifdef DOSISH_DRIVE_LETTER
3935 if (has_drive_letter(name) &&
isdirsep(*(name + 2))) {
3943 #ifdef DOSISH_DRIVE_LETTER
3944 if (has_drive_letter(name) && root == name + 2 && p - name == 2)
3967 const char *p, *e, *end = name + (len ? *len : (long)
strlen(name));
3973 do name = ++p;
while (
isdirsep(*p));
3976 while (*p && *p ==
'.') p++;
3980 const char *last = p++, *dot =
last;
3982 if (*p ==
'.') dot = p;
3985 if (!*p || *p ==
':') {
3989 if (*last ==
'.' || dot > last) e = dot;
3996 else if (*p ==
':') {
4007 if (!e || e == name)
4042 const char *
name, *e;
4135 switch (
TYPE(tmp)) {
4160 else if (!
NIL_P(sep)) {
4197 #if defined(HAVE_TRUNCATE) || defined(HAVE_CHSIZE)
4216 #ifdef HAVE_TRUNCATE
4217 #define NUM2POS(n) NUM2OFFT(n)
4220 #define NUM2POS(n) NUM2LONG(n)
4228 #ifdef HAVE_TRUNCATE
4239 if (chsize(tmpfd, pos) < 0) {
4250 #define rb_file_s_truncate rb_f_notimplement
4253 #if defined(HAVE_FTRUNCATE) || defined(HAVE_CHSIZE)
4272 #if defined(HAVE_FTRUNCATE)
4273 #define NUM2POS(n) NUM2OFFT(n)
4276 #define NUM2POS(n) NUM2LONG(n)
4287 #ifdef HAVE_FTRUNCATE
4291 if (chsize(fptr->
fd, pos) < 0)
4298 #define rb_file_truncate rb_f_notimplement
4315 #include <winerror.h>
4322 int old_errno =
errno;
4324 int *op = data, ret =
flock(op[0], op[1]);
4327 if (GetLastError() == ERROR_NOT_LOCKED) {
4387 op[1] = op1 =
NUM2INT(operation);
4398 #if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
4410 #if defined(ERESTART)
4431 for (i=1; i<n; i++) {
4438 #define CHECK(n) test_check((n), argc, argv)
4515 if (
strchr(
"bcdefgGkloOprRsSuwWxXz", cmd)) {
4587 if (
strchr(
"MAC", cmd)) {
4589 VALUE fname = argv[1];
4592 if (
rb_stat(fname, &st) == -1) {
4612 if (
strchr(
"=<>", cmd)) {
4613 struct stat st1, st2;
4621 if (st1.st_mtime == st2.st_mtime)
return Qtrue;
4625 if (st1.st_mtime > st2.st_mtime)
return Qtrue;
4629 if (st1.st_mtime < st2.st_mtime)
return Qtrue;
4669 struct stat st, *nst;
5206 if (size == 0)
return Qnil;
5283 #ifdef DOSISH_DRIVE_LETTER
5284 if (has_drive_letter(path) &&
isdirsep(path[2]))
return 1;
5290 if (path[0] ==
'/')
return 1;
5295 #ifndef ENABLE_PATH_CHECK
5296 # if defined DOSISH || defined __CYGWIN__
5297 # define ENABLE_PATH_CHECK 0
5299 # define ENABLE_PATH_CHECK 1
5303 #if ENABLE_PATH_CHECK
5329 # define S_IWOTH 002
5333 && !(p && execpath && (st.st_mode & S_ISVTX))
5336 rb_warn(
"Insecure world writable dir %s in %sPATH, mode 0%"
5337 PRI_MODET_PREFIX
"o",
5338 p0, (execpath ?
"" :
"LOAD_"), st.st_mode);
5345 if (!s || s == p0)
return 1;
5353 #if ENABLE_PATH_CHECK
5354 #define fpath_check(path) path_check_0((path), FALSE)
5356 #define fpath_check(path) 1
5362 #if ENABLE_PATH_CHECK
5363 const char *p0, *p, *pend;
5366 if (!path)
return 1;
5368 pend = path +
strlen(path);
5378 if (p0 > pend)
break;
5387 #ifdef __native_client__
5388 __attribute__((noinline))
5395 if (fd == -1)
return 0;
5413 if (*path++ !=
'.')
return 0;
5414 if (*path ==
'.') path++;
5437 VALUE fname = *filep, load_path, tmp;
5441 if (!ext[0])
return 0;
5459 for (i=0; ext[i]; i++) {
5471 if (!load_path)
return 0;
5478 for (j=0; ext[j]; j++) {
5480 for (i = 0; i <
RARRAY_LEN(load_path); i++) {
5507 VALUE tmp, load_path;
5537 for (i = 0; i <
RARRAY_LEN(load_path); i++) {
5570 #elif defined AMIGA || defined __amigaos__
5740 #if defined(O_NDELAY) || defined(O_NONBLOCK)
5742 # define O_NONBLOCK O_NDELAY
RUBY_EXTERN VALUE rb_cString
static VALUE rb_file_exists_p(VALUE obj, VALUE fname)
#define RBASIC_CLEAR_CLASS(obj)
static VALUE rb_stat_ino(VALUE self)
VALUE rb_get_path_check_convert(VALUE obj, VALUE tmp, int level)
VALUE rb_get_path(VALUE obj)
#define MBCLEN_CHARFOUND_P(ret)
rb_encoding * rb_enc_check(VALUE str1, VALUE str2)
static VALUE rb_file_socket_p(VALUE obj, VALUE fname)
#define MBCLEN_CHARFOUND_LEN(ret)
static VALUE rb_file_s_mtime(VALUE klass, VALUE fname)
#define rb_enc_mbc_to_codepoint(p, e, enc)
static VALUE stat_mtime(struct stat *st)
void rb_enc_copy(VALUE obj1, VALUE obj2)
#define RUBY_TYPED_FREE_IMMEDIATELY
static VALUE rb_file_sgid_p(VALUE obj, VALUE fname)
static struct timespec stat_atimespec(struct stat *st)
size_t strlen(const char *)
static VALUE rb_get_path_check(VALUE obj, int level)
static VALUE rb_stat_z(VALUE obj)
void rb_update_max_fd(int fd)
static VALUE rb_stat_init(VALUE obj, VALUE fname)
VALUE rb_time_nano_new(time_t, long)
static VALUE rb_file_executable_p(VALUE obj, VALUE fname)
static VALUE rb_stat_rdev(VALUE self)
static VALUE rb_stat_cmp(VALUE self, VALUE other)
int rb_is_absolute_path(const char *path)
static VALUE rb_stat_init_copy(VALUE copy, VALUE orig)
static VALUE rb_file_grpowned_p(VALUE obj, VALUE fname)
void rb_define_singleton_method(VALUE obj, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a singleton method for obj.
#define skipprefix(path, end, enc)
#define access(path, mode)
static VALUE rb_file_size_p(VALUE obj, VALUE fname)
#define expand_path(fname, dname, abs_mode, long_name, result)
static VALUE rb_file_s_size(VALUE klass, VALUE fname)
#define rb_usascii_str_new2
int rb_cloexec_open(const char *pathname, int flags, mode_t mode)
void rb_file_const(const char *name, VALUE value)
VALUE rb_str_cat(VALUE, const char *, long)
static VALUE rb_f_test(int argc, VALUE *argv)
static VALUE rb_stat_mode(VALUE self)
int rb_find_file_ext(VALUE *filep, const char *const *ext)
static VALUE rb_file_world_writable_p(VALUE obj, VALUE fname)
static VALUE rb_file_readable_p(VALUE obj, VALUE fname)
static VALUE rb_stat_f(VALUE obj)
#define TypedData_Wrap_Struct(klass, data_type, sval)
#define OBJ_INIT_COPY(obj, orig)
void rb_io_check_initialized(rb_io_t *)
#define TypedData_Get_Struct(obj, type, data_type, sval)
VALUE rb_get_path_check_to_string(VALUE obj, int level)
const struct timespec * tsp
#define ENC_CODERANGE_CLEAR(obj)
VALUE rb_enc_from_encoding(rb_encoding *encoding)
SOCKET rb_w32_get_osfhandle(int)
int eaccess(const char *path, int mode)
rb_encoding * rb_default_internal_encoding(void)
VALUE rb_str_buf_new2(const char *)
static VALUE rb_file_flock(VALUE obj, VALUE operation)
const char * ruby_enc_find_basename(const char *name, long *baselen, long *alllen, rb_encoding *enc)
VALUE rb_str_plus(VALUE, VALUE)
rb_encoding * rb_enc_compatible(VALUE str1, VALUE str2)
VALUE rb_file_s_expand_path(int argc, VALUE *argv)
#define FilePathStringValue(v)
static VALUE rb_stat_blocks(VALUE self)
void rb_str_set_len(VALUE, long)
static VALUE copy_path_class(VALUE path, VALUE orig)
#define RBASIC_SET_CLASS(obj, cls)
int rb_enc_str_coderange(VALUE)
unsigned int rb_enc_codepoint_len(const char *p, const char *e, int *len_p, rb_encoding *enc)
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super)
Defines a class under the namespace of outer.
void rb_raise(VALUE exc, const char *fmt,...)
static long apply2files(void(*func)(const char *, VALUE, void *), VALUE vargs, void *arg)
static struct timespec stat_mtimespec(struct stat *st)
#define RSTRING_GETMEM(str, ptrvar, lenvar)
VALUE rb_enc_associate(VALUE obj, rb_encoding *enc)
static VALUE rb_stat_w(VALUE obj)
VALUE rb_io_taint_check(VALUE)
VALUE rb_exec_recursive(VALUE(*)(VALUE, VALUE, int), VALUE, VALUE)
void rb_define_alloc_func(VALUE, rb_alloc_func_t)
VALUE rb_obj_is_kind_of(VALUE, VALUE)
static VALUE rb_file_zero_p(VALUE obj, VALUE fname)
static VALUE rb_stat_d(VALUE obj)
static VALUE file_inspect_join(VALUE ary, VALUE argp, int recur)
VALUE rb_thread_io_blocking_region(rb_blocking_function_t *func, void *data1, int fd)
static VALUE rb_file_size(VALUE obj)
void rb_include_module(VALUE klass, VALUE module)
static VALUE file_path_convert(VALUE name)
static VALUE rb_file_lstat(VALUE obj)
static VALUE rb_stat_dev_minor(VALUE self)
static VALUE rb_file_suid_p(VALUE obj, VALUE fname)
static VALUE rb_file_s_basename(int argc, VALUE *argv)
int rb_str_cmp(VALUE, VALUE)
static VALUE rb_stat_S(VALUE obj)
static VALUE file_expand_path_1(VALUE fname)
void rb_define_global_function(const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a global function.
static VALUE rb_file_s_utime(int argc, VALUE *argv)
static VALUE rb_stat_s(VALUE obj)
static VALUE rb_stat_dev(VALUE self)
rb_encoding * rb_utf8_encoding(void)
static void realpath_rec(long *prefixlenp, VALUE *resolvedp, const char *unresolved, VALUE loopcheck, int strict, int last)
static void sys_fail2(VALUE s1, VALUE s2)
VALUE rb_str_dup_frozen(VALUE)
static VALUE rb_file_ctime(VALUE obj)
static VALUE rb_stat_uid(VALUE self)
VALUE rb_str_tmp_new(long)
VALUE rb_str_buf_append(VALUE, VALUE)
#define GetOpenFile(obj, fp)
static VALUE rb_stat_r(VALUE obj)
static VALUE rb_stat_grpowned(VALUE obj)
int truncate(const char *path, off_t new_size)
#define ENC_CODERANGE_7BIT
const char * rb_obj_classname(VALUE)
struct timespec rb_time_timespec(VALUE time)
static VALUE rb_stat_x(VALUE obj)
VALUE rb_str_buf_cat(VALUE, const char *, long)
static char * chompdirsep(const char *path, const char *end, rb_encoding *enc)
#define rb_file_s_readlink
void rb_exc_raise(VALUE mesg)
static VALUE rb_file_blockdev_p(VALUE obj, VALUE fname)
char * rb_enc_path_skip_prefix(const char *path, const char *end, rb_encoding *enc)
static VALUE rb_file_world_readable_p(VALUE obj, VALUE fname)
#define RBASIC_SET_CLASS_RAW(obj, cls)
static VALUE rb_stat_s_alloc(VALUE klass)
#define RB_TYPE_P(obj, type)
int utimes(const char *filename, const struct timeval times[2])
static VALUE rb_file_ftype(const struct stat *st)
static VALUE rb_thread_flock(void *data)
static int path_check_0(VALUE path, int execpath)
static VALUE stat_ctime(struct stat *st)
static rb_encoding * check_path_encoding(VALUE str)
static VALUE rb_stat_size(VALUE self)
static VALUE rb_file_s_split(VALUE klass, VALUE path)
static VALUE stat_new_0(VALUE klass, const struct stat *st)
static VALUE rb_file_pipe_p(VALUE obj, VALUE fname)
VALUE rb_find_file(VALUE path)
VALUE rb_class_new_instance(int, VALUE *, VALUE)
static VALUE rb_file_s_chmod(int argc, VALUE *argv)
VALUE rb_hash_aset(VALUE hash, VALUE key, VALUE val)
static VALUE rb_file_s_lstat(VALUE klass, VALUE fname)
VALUE rb_str_new_shared(VALUE)
VALUE rb_obj_taint(VALUE)
VALUE rb_str_encode_ospath(VALUE path)
static VALUE rb_file_readable_real_p(VALUE obj, VALUE fname)
#define rb_file_s_symlink
RUBY_EXTERN VALUE rb_cObject
VALUE rb_home_dir_of(VALUE user, VALUE result)
static VALUE rb_file_s_stat(VALUE klass, VALUE fname)
static VALUE rb_file_mtime(VALUE obj)
static VALUE rb_file_s_chown(int argc, VALUE *argv)
static VALUE rb_file_s_realpath(int argc, VALUE *argv, VALUE klass)
static VALUE rb_stat_owned(VALUE obj)
VALUE rb_str_cat2(VALUE, const char *)
VALUE rb_str_buf_cat2(VALUE, const char *)
static int is_explicit_relative(const char *path)
VALUE rb_define_class(const char *name, VALUE super)
Defines a top-level class.
static VALUE rb_file_exist_p(VALUE obj, VALUE fname)
int chown(const char *, int, int)
static VALUE str_shrink(VALUE str)
void rb_define_const(VALUE, const char *, VALUE)
static char * skiproot(const char *path, const char *end, rb_encoding *enc)
VALUE rb_class_inherited_p(VALUE, VALUE)
char * rb_enc_path_next(const char *s, const char *e, rb_encoding *enc)
VALUE rb_str_conv_enc(VALUE str, rb_encoding *from, rb_encoding *to)
VALUE rb_io_flush_raw(VALUE, int)
#define insecure_obj_p(obj, level)
static VALUE rb_file_sticky_p(VALUE obj, VALUE fname)
static VALUE rb_file_s_join(VALUE klass, VALUE args)
static VALUE rb_file_atime(VALUE obj)
#define ALLOCV_N(type, v, n)
static size_t stat_memsize(const void *p)
mode_t umask(mode_t mask)
static VALUE rb_stat_b(VALUE obj)
#define ALLOCA_N(type, n)
#define fpath_check(path)
void rb_enc_raise(rb_encoding *enc, VALUE exc, const char *fmt,...)
VALUE rb_enc_associate_index(VALUE obj, int idx)
static void chmod_internal(const char *path, VALUE pathv, void *mode)
VALUE rb_find_file_safe(VALUE path, int safe_level)
static VALUE rb_stat_suid(VALUE obj)
int link(const char *, const char *)
static VALUE rb_file_writable_real_p(VALUE obj, VALUE fname)
static VALUE rb_stat_sticky(VALUE obj)
static VALUE rb_stat_ftype(VALUE obj)
static char * append_fspath(VALUE result, VALUE fname, char *dir, rb_encoding **enc, rb_encoding *fsenc)
VALUE rb_file_absolute_path(VALUE fname, VALUE dname)
VALUE rb_str_resize(VALUE, long)
size_t rb_str_capacity(VALUE)
int rb_enc_ascget(const char *p, const char *e, int *len, rb_encoding *enc)
VALUE rb_str_subseq(VALUE, long, long)
static VALUE rb_stat_blksize(VALUE self)
static VALUE rb_file_identical_p(VALUE obj, VALUE fname1, VALUE fname2)
void rb_define_module_function(VALUE module, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a module function for module.
SSL_METHOD *(* func)(void)
VALUE rb_file_s_absolute_path(int argc, VALUE *argv)
VALUE rb_sprintf(const char *format,...)
int rb_enc_precise_mbclen(const char *p, const char *e, rb_encoding *enc)
VALUE rb_eSystemCallError
static VALUE rb_file_s_path(VALUE klass, VALUE fname)
static VALUE rb_stat_dev_major(VALUE self)
VALUE rb_file_dirname(VALUE fname)
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
static char * skipprefixroot(const char *path, const char *end, rb_encoding *enc)
void rb_str_modify_expand(VALUE, long)
static VALUE rb_stat_ctime(VALUE self)
unsigned char buf[MIME_BUF_SIZE]
VALUE rb_assoc_new(VALUE car, VALUE cdr)
rb_encoding * rb_usascii_encoding(void)
VALUE rb_file_directory_p(VALUE obj, VALUE fname)
static int rb_group_member(GETGROUPS_T gid)
int ftruncate(int fd, off_t new_size)
#define EXPAND_PATH_BUFFER()
#define check_expand_path_args(fname, dname)
static VALUE rb_stat_sgid(VALUE obj)
char * strchr(char *, char)
static VALUE rb_stat_inspect(VALUE self)
#define rb_usascii_encindex()
VALUE rb_check_funcall(VALUE, ID, int, const VALUE *)
#define rb_enc_asciicompat(enc)
static VALUE rb_file_writable_p(VALUE obj, VALUE fname)
VALUE rb_str_ellipsize(VALUE, long)
Shortens str and adds three dots, an ellipsis, if it is longer than len characters.
VALUE rb_str_new_cstr(const char *)
static void utime_internal(const char *path, VALUE pathv, void *arg)
static VALUE copy_home_path(VALUE result, const char *dir)
static struct timespec stat_ctimespec(struct stat *st)
static void chown_internal(const char *path, VALUE pathv, void *arg)
static void test_check(int n, int argc, VALUE *argv)
VALUE rb_stat_new(const struct stat *st)
VALUE rb_define_module_under(VALUE outer, const char *name)
#define StringValueCStr(v)
static VALUE rb_stat_wr(VALUE obj)
static VALUE rb_stat_mtime(VALUE self)
void rb_thread_wait_for(struct timeval)
#define ENCODING_GET(obj)
VALUE rb_equal(VALUE, VALUE)
rb_encoding * rb_enc_get(VALUE obj)
#define utime_failed(path, tsp, atime, mtime)
void rb_insecure_operation(void)
static const char null_device[]
int utime(const char *filename, const struct utimbuf *times)
static VALUE rb_file_s_ftype(VALUE klass, VALUE fname)
#define RARRAY_AREF(a, i)
int rb_path_check(const char *path)
VALUE rb_check_convert_type(VALUE, int, const char *, const char *)
NORETURN(static void sys_fail2(VALUE, VALUE))
VALUE rb_file_expand_path(VALUE fname, VALUE dname)
static const rb_data_type_t stat_data_type
static VALUE rb_file_chown(VALUE obj, VALUE owner, VALUE group)
static VALUE rb_stat_rowned(VALUE obj)
static VALUE rb_stat_c(VALUE obj)
static VALUE rb_file_s_extname(VALUE klass, VALUE fname)
VALUE rb_hash_aref(VALUE hash, VALUE key)
static VALUE rb_file_chmod(VALUE obj, VALUE vmode)
VALUE rb_str_catf(VALUE str, const char *format,...)
static VALUE rb_file_chardev_p(VALUE obj, VALUE fname)
static VALUE stat_atime(struct stat *st)
static VALUE rb_file_s_dirname(VALUE klass, VALUE fname)
static VALUE rb_file_owned_p(VALUE obj, VALUE fname)
VALUE rb_default_home_dir(VALUE result)
static void unlink_internal(const char *path, VALUE pathv, void *arg)
rb_encoding * rb_filesystem_encoding(void)
static VALUE rb_stat_atime(VALUE self)
static VALUE rb_stat_gid(VALUE self)
static VALUE rb_file_rowned_p(VALUE obj, VALUE fname)
static size_t rmext(const char *p, long l0, long l1, const char *e, long l2, rb_encoding *enc)
#define rb_enc_left_char_head(s, p, e, enc)
VALUE rb_str_inspect(VALUE)
static VALUE rb_file_s_rename(VALUE klass, VALUE from, VALUE to)
static VALUE rb_stat_p(VALUE obj)
VALUE rb_get_expanded_load_path(void)
static VALUE rb_stat_rdev_major(VALUE self)
char * rb_enc_path_end(const char *path, const char *end, rb_encoding *enc)
static struct stat * get_stat(VALUE self)
VALUE rb_enc_str_new(const char *, long, rb_encoding *)
static int rb_stat(VALUE file, struct stat *st)
#define rb_sys_fail_path(path)
static VALUE rb_stat_X(VALUE obj)
VALUE rb_realpath_internal(VALUE basedir, VALUE path, int strict)
#define istrailinggarbage(x)
char * rb_enc_path_last_separator(const char *path, const char *end, rb_encoding *enc)
RUBY_EXTERN VALUE rb_eIOError
static VALUE rb_file_executable_real_p(VALUE obj, VALUE fname)
int rb_find_file_ext_safe(VALUE *filep, const char *const *ext, int safe_level)
int rb_file_load_ok(const char *path)
static VALUE rb_stat_ww(VALUE obj)
RUBY_EXTERN size_t strlcat(char *, const char *, size_t)
static VALUE rb_file_s_ctime(VALUE klass, VALUE fname)
static VALUE rb_file_path(VALUE obj)
static VALUE rb_io_stat(VALUE obj)
#define StringValuePtr(v)
#define STRCASECMP(s1, s2)
rb_encoding * rb_ascii8bit_encoding(void)
void rb_warning(const char *fmt,...)
#define CONST_ID(var, str)
#define RUBY_TYPED_DEFAULT_FREE
static VALUE rb_stat_nlink(VALUE self)
VALUE rb_obj_freeze(VALUE)
VALUE rb_str_encode(VALUE str, VALUE to, int ecflags, VALUE ecopts)
VALUE rb_define_module(const char *name)
int rb_enc_str_asciionly_p(VALUE)
const char * ruby_enc_find_extname(const char *name, long *len, rb_encoding *enc)
VALUE rb_str_buf_new(long)
static VALUE rb_file_s_umask(int argc, VALUE *argv)
VALUE rb_get_path_no_checksafe(VALUE obj)
#define rb_file_s_truncate
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
VALUE rb_str_append(VALUE, VALUE)
static VALUE rb_stat_rdev_minor(VALUE self)
static VALUE rb_stat_l(VALUE obj)
static VALUE rb_file_s_realdirpath(int argc, VALUE *argv, VALUE klass)
static VALUE rb_file_s_unlink(VALUE klass, VALUE args)
static VALUE rb_file_join(VALUE ary, VALUE sep)
int rb_memcicmp(const void *, const void *, long)
void rb_warn(const char *fmt,...)
void rb_io_check_closed(rb_io_t *)
static VALUE rb_stat_W(VALUE obj)
static VALUE rb_file_s_atime(VALUE klass, VALUE fname)
VALUE rb_file_expand_path_internal(VALUE fname, VALUE dname, int abs_mode, int long_name, VALUE result)
static VALUE rb_stat_R(VALUE obj)
VALUE rb_file_expand_path_fast(VALUE fname, VALUE dname)
static void define_filetest_function(const char *name, VALUE(*func)(ANYARGS), int argc)
rb_encoding * rb_enc_from_index(int index)
VALUE rb_str_new(const char *, long)
VALUE rb_obj_class(VALUE)
static VALUE rb_file_file_p(VALUE obj, VALUE fname)
static VALUE rb_file_symlink_p(VALUE obj, VALUE fname)