Ruby  2.4.2p198(2017-09-14revision59899)
Data Structures | Macros | Functions | Variables
file.c File Reference
#include "internal.h"
#include "ruby/io.h"
#include "ruby/util.h"
#include "dln.h"
#include "encindex.h"
#include <ctype.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
Include dependency graph for file.c:

Go to the source code of this file.

Data Structures

struct  chown_args
 
struct  utime_args
 
struct  utimbuf
 

Macros

#define MAXPATHLEN   1024
 
#define lstat   stat
 
#define STAT(p, s)   stat((p), (s))
 
#define insecure_obj_p(obj, level)   ((level) > 0 && OBJ_TAINTED(obj))
 
#define NORMALIZE_UTF8PATH   0
 
#define apply2args(n)   (rb_check_arity(argc, n, UNLIMITED_ARGUMENTS), argc-=n)
 
#define ST2UINT(val)   ((val) & ~(~1UL << (sizeof(val) * CHAR_BIT - 1)))
 
#define NUM2DEVT(v)   NUM2UINT(v)
 
#define DEVT2NUM(v)   UINT2NUM(v)
 
#define PRI_DEVT_PREFIX   ""
 
#define HAVE_STAT_BIRTHTIME
 
#define rb_stat_birthtime   rb_f_notimplement
 
#define S_IXUGO   (S_IXUSR | S_IXGRP | S_IXOTH)
 
#define S_ISDIR(m)   (((m) & S_IFMT) == S_IFDIR)
 
#define S_ISBLK(m)   (0) /* anytime false */
 
#define S_ISCHR(m)   (((m) & S_IFMT) == S_IFCHR)
 
#define S_IRUGO   (S_IRUSR | S_IRGRP | S_IROTH)
 
#define S_IWUGO   (S_IWUSR | S_IWGRP | S_IWOTH)
 
#define S_ISREG(m)   (((m) & S_IFMT) == S_IFREG)
 
#define rb_file_s_birthtime   rb_f_notimplement
 
#define rb_file_birthtime   rb_f_notimplement
 
#define rb_file_s_lchmod   rb_f_notimplement
 
#define rb_file_s_lchown   rb_f_notimplement
 
#define utime_failed(path, tsp, atime, mtime)   rb_sys_fail_path(path)
 
#define syserr_fail2_in(func, e, s1, s2)   syserr_fail2(e, s1, s2)
 
#define sys_fail2(s1, s2)   syserr_fail2(errno, s1, s2)
 
#define rb_file_s_link   rb_f_notimplement
 
#define rb_file_s_symlink   rb_f_notimplement
 
#define rb_file_s_readlink   rb_f_notimplement
 
#define isdirsep(x)   ((x) == '/')
 
#define USE_NTFS   0
 
#define USE_NTFS_ADS   0
 
#define istrailinggarbage(x)   0
 
#define isADS(x)   0
 
#define Next(p, e, enc)   ((p) + rb_enc_mbclen((p), (e), (enc)))
 
#define Inc(p, e, enc)   ((p) = Next((p), (e), (enc)))
 
#define has_unc(buf)   0
 
#define nextdirsep   rb_enc_path_next
 
#define skipprefix(path, end, enc)   (path)
 
#define strrdirsep   rb_enc_path_last_separator
 
#define BUFCHECK(cond)
 
#define BUFINIT()
 
#define SKIPPATHSEP(p)   1
 
#define BUFCOPY(srcptr, srclen)
 
#define WITH_ROOTDIFF(stmt)
 
#define endpwent()   ((void)0)
 
#define EXPAND_PATH_BUFFER()   rb_usascii_str_new(0, MAXPATHLEN + 2)
 
#define expand_path(fname, dname, abs_mode, long_name, result)   str_shrink(rb_file_expand_path_internal(fname, dname, abs_mode, long_name, result))
 
#define check_expand_path_args(fname, dname)
 
#define fncomp   strncmp
 
#define rb_file_s_truncate   rb_f_notimplement
 
#define rb_file_truncate   rb_f_notimplement
 
#define LOCK_SH   1
 
#define LOCK_EX   2
 
#define LOCK_NB   4
 
#define LOCK_UN   8
 
#define CHECK(n)   test_check((n), argc, argv)
 
#define rb_file_s_mkfifo   rb_f_notimplement
 
#define ENABLE_PATH_CHECK   1
 
#define S_IWOTH   002
 
#define fpath_check(path)   path_check_0((path), FALSE)
 
#define O_BINARY   0
 
#define O_SHARE_DELETE   0
 

Functions

int flock (int, int)
 
static VALUE file_path_convert (VALUE name)
 
static rb_encodingcheck_path_encoding (VALUE str)
 
VALUE rb_get_path_check_to_string (VALUE obj, int level)
 
VALUE rb_get_path_check_convert (VALUE obj, VALUE tmp, int level)
 
static VALUE rb_get_path_check (VALUE obj, int level)
 
VALUE rb_get_path_no_checksafe (VALUE obj)
 
VALUE rb_get_path (VALUE obj)
 
VALUE rb_str_encode_ospath (VALUE path)
 
static VALUE apply2files (void(*func)(const char *, VALUE, void *), int argc, VALUE *argv, void *arg)
 
static VALUE rb_file_path (VALUE obj)
 
static size_t stat_memsize (const void *p)
 
static VALUE stat_new_0 (VALUE klass, const struct stat *st)
 
VALUE rb_stat_new (const struct stat *st)
 
static struct statget_stat (VALUE self)
 
static struct timespec stat_mtimespec (struct stat *st)
 
static VALUE rb_stat_cmp (VALUE self, VALUE other)
 
static VALUE rb_stat_dev (VALUE self)
 
static VALUE rb_stat_dev_major (VALUE self)
 
static VALUE rb_stat_dev_minor (VALUE self)
 
static VALUE rb_stat_ino (VALUE self)
 
static VALUE rb_stat_mode (VALUE self)
 
static VALUE rb_stat_nlink (VALUE self)
 
static VALUE rb_stat_uid (VALUE self)
 
static VALUE rb_stat_gid (VALUE self)
 
static VALUE rb_stat_rdev (VALUE self)
 
static VALUE rb_stat_rdev_major (VALUE self)
 
static VALUE rb_stat_rdev_minor (VALUE self)
 
static VALUE rb_stat_size (VALUE self)
 
static VALUE rb_stat_blksize (VALUE self)
 
static VALUE rb_stat_blocks (VALUE self)
 
static struct timespec stat_atimespec (struct stat *st)
 
static VALUE stat_atime (struct stat *st)
 
static VALUE stat_mtime (struct stat *st)
 
static struct timespec stat_ctimespec (struct stat *st)
 
static VALUE stat_ctime (struct stat *st)
 
static VALUE rb_stat_atime (VALUE self)
 
static VALUE rb_stat_mtime (VALUE self)
 
static VALUE rb_stat_ctime (VALUE self)
 
static VALUE rb_stat_inspect (VALUE self)
 
static int rb_stat (VALUE file, struct stat *st)
 
static VALUE rb_file_s_stat (VALUE klass, VALUE fname)
 
static VALUE rb_io_stat (VALUE obj)
 
static VALUE rb_file_s_lstat (VALUE klass, VALUE fname)
 
static VALUE rb_file_lstat (VALUE obj)
 
static int rb_group_member (GETGROUPS_T gid)
 
int eaccess (const char *path, int mode)
 
VALUE rb_file_directory_p (VALUE obj, VALUE fname)
 
static VALUE rb_file_pipe_p (VALUE obj, VALUE fname)
 
static VALUE rb_file_symlink_p (VALUE obj, VALUE fname)
 
static VALUE rb_file_socket_p (VALUE obj, VALUE fname)
 
static VALUE rb_file_blockdev_p (VALUE obj, VALUE fname)
 
static VALUE rb_file_chardev_p (VALUE obj, VALUE fname)
 
static VALUE rb_file_exist_p (VALUE obj, VALUE fname)
 
static VALUE rb_file_exists_p (VALUE obj, VALUE fname)
 
static VALUE rb_file_readable_p (VALUE obj, VALUE fname)
 
static VALUE rb_file_readable_real_p (VALUE obj, VALUE fname)
 
static VALUE rb_file_world_readable_p (VALUE obj, VALUE fname)
 
static VALUE rb_file_writable_p (VALUE obj, VALUE fname)
 
static VALUE rb_file_writable_real_p (VALUE obj, VALUE fname)
 
static VALUE rb_file_world_writable_p (VALUE obj, VALUE fname)
 
static VALUE rb_file_executable_p (VALUE obj, VALUE fname)
 
static VALUE rb_file_executable_real_p (VALUE obj, VALUE fname)
 
static VALUE rb_file_file_p (VALUE obj, VALUE fname)
 
static VALUE rb_file_zero_p (VALUE obj, VALUE fname)
 
static VALUE rb_file_size_p (VALUE obj, VALUE fname)
 
static VALUE rb_file_owned_p (VALUE obj, VALUE fname)
 
static VALUE rb_file_rowned_p (VALUE obj, VALUE fname)
 
static VALUE rb_file_grpowned_p (VALUE obj, VALUE fname)
 
static VALUE rb_file_suid_p (VALUE obj, VALUE fname)
 
static VALUE rb_file_sgid_p (VALUE obj, VALUE fname)
 
static VALUE rb_file_sticky_p (VALUE obj, VALUE fname)
 
static VALUE rb_file_identical_p (VALUE obj, VALUE fname1, VALUE fname2)
 
static VALUE rb_file_s_size (VALUE klass, VALUE fname)
 
static VALUE rb_file_ftype (const struct stat *st)
 
static VALUE rb_file_s_ftype (VALUE klass, VALUE fname)
 
static VALUE rb_file_s_atime (VALUE klass, VALUE fname)
 
static VALUE rb_file_atime (VALUE obj)
 
static VALUE rb_file_s_mtime (VALUE klass, VALUE fname)
 
static VALUE rb_file_mtime (VALUE obj)
 
static VALUE rb_file_s_ctime (VALUE klass, VALUE fname)
 
static VALUE rb_file_ctime (VALUE obj)
 
static VALUE rb_file_size (VALUE obj)
 
static void chmod_internal (const char *path, VALUE pathv, void *mode)
 
static VALUE rb_file_s_chmod (int argc, VALUE *argv)
 
static VALUE rb_file_chmod (VALUE obj, VALUE vmode)
 
static rb_uid_t to_uid (VALUE u)
 
static rb_gid_t to_gid (VALUE g)
 
static void chown_internal (const char *path, VALUE pathv, void *arg)
 
static VALUE rb_file_s_chown (int argc, VALUE *argv)
 
static VALUE rb_file_chown (VALUE obj, VALUE owner, VALUE group)
 
static void utime_internal (const char *path, VALUE pathv, void *arg)
 
static VALUE rb_file_s_utime (int argc, VALUE *argv)
 
 NORETURN (static void syserr_fail2_in(const char *, int, VALUE, VALUE))
 
static void syserr_fail2_in (const char *func, int e, VALUE s1, VALUE s2)
 
static void unlink_internal (const char *path, VALUE pathv, void *arg)
 
static VALUE rb_file_s_unlink (int argc, VALUE *argv, VALUE klass)
 
static VALUE rb_file_s_rename (VALUE klass, VALUE from, VALUE to)
 
static VALUE rb_file_s_umask (int argc, VALUE *argv)
 
static char * skiproot (const char *path, const char *end, rb_encoding *enc)
 
char * rb_enc_path_next (const char *s, const char *e, rb_encoding *enc)
 
char * rb_enc_path_skip_prefix (const char *path, const char *end, rb_encoding *enc)
 
static char * skipprefixroot (const char *path, const char *end, rb_encoding *enc)
 
char * rb_enc_path_last_separator (const char *path, const char *end, rb_encoding *enc)
 
static char * chompdirsep (const char *path, const char *end, rb_encoding *enc)
 
char * rb_enc_path_end (const char *path, const char *end, rb_encoding *enc)
 
static VALUE copy_home_path (VALUE result, const char *dir)
 
VALUE rb_home_dir_of (VALUE user, VALUE result)
 
VALUE rb_default_home_dir (VALUE result)
 
static VALUE ospath_new (const char *ptr, long len, rb_encoding *fsenc)
 
static char * append_fspath (VALUE result, VALUE fname, char *dir, rb_encoding **enc, rb_encoding *fsenc)
 
VALUE rb_file_expand_path_internal (VALUE fname, VALUE dname, int abs_mode, int long_name, VALUE result)
 
static VALUE str_shrink (VALUE str)
 
static VALUE file_expand_path_1 (VALUE fname)
 
VALUE rb_file_expand_path (VALUE fname, VALUE dname)
 
VALUE rb_file_expand_path_fast (VALUE fname, VALUE dname)
 
VALUE rb_file_s_expand_path (int argc, const VALUE *argv)
 
VALUE rb_file_absolute_path (VALUE fname, VALUE dname)
 
VALUE rb_file_s_absolute_path (int argc, const VALUE *argv)
 
static void realpath_rec (long *prefixlenp, VALUE *resolvedp, const char *unresolved, VALUE loopcheck, int strict, int last)
 
VALUE rb_realpath_internal (VALUE basedir, VALUE path, int strict)
 
static VALUE rb_file_s_realpath (int argc, VALUE *argv, VALUE klass)
 
static VALUE rb_file_s_realdirpath (int argc, VALUE *argv, VALUE klass)
 
static size_t rmext (const char *p, long l0, long l1, const char *e, long l2, rb_encoding *enc)
 
const char * ruby_enc_find_basename (const char *name, long *baselen, long *alllen, rb_encoding *enc)
 
static VALUE rb_file_s_basename (int argc, VALUE *argv)
 
static VALUE rb_file_s_dirname (VALUE klass, VALUE fname)
 
VALUE rb_file_dirname (VALUE fname)
 
const char * ruby_enc_find_extname (const char *name, long *len, rb_encoding *enc)
 
static VALUE rb_file_s_extname (VALUE klass, VALUE fname)
 
static VALUE rb_file_s_path (VALUE klass, VALUE fname)
 
static VALUE rb_file_s_split (VALUE klass, VALUE path)
 
static VALUE rb_file_join (VALUE ary, VALUE sep)
 
static VALUE file_inspect_join (VALUE ary, VALUE argp, int recur)
 
static VALUE rb_file_s_join (VALUE klass, VALUE args)
 
static VALUE rb_thread_flock (void *data)
 
static VALUE rb_file_flock (VALUE obj, VALUE operation)
 
static void test_check (int n, int argc, VALUE *argv)
 
static VALUE rb_f_test (int argc, VALUE *argv)
 
static VALUE rb_stat_s_alloc (VALUE klass)
 
static VALUE rb_stat_init (VALUE obj, VALUE fname)
 
static VALUE rb_stat_init_copy (VALUE copy, VALUE orig)
 
static VALUE rb_stat_ftype (VALUE obj)
 
static VALUE rb_stat_d (VALUE obj)
 
static VALUE rb_stat_p (VALUE obj)
 
static VALUE rb_stat_l (VALUE obj)
 
static VALUE rb_stat_S (VALUE obj)
 
static VALUE rb_stat_b (VALUE obj)
 
static VALUE rb_stat_c (VALUE obj)
 
static VALUE rb_stat_owned (VALUE obj)
 
static VALUE rb_stat_rowned (VALUE obj)
 
static VALUE rb_stat_grpowned (VALUE obj)
 
static VALUE rb_stat_r (VALUE obj)
 
static VALUE rb_stat_R (VALUE obj)
 
static VALUE rb_stat_wr (VALUE obj)
 
static VALUE rb_stat_w (VALUE obj)
 
static VALUE rb_stat_W (VALUE obj)
 
static VALUE rb_stat_ww (VALUE obj)
 
static VALUE rb_stat_x (VALUE obj)
 
static VALUE rb_stat_X (VALUE obj)
 
static VALUE rb_stat_f (VALUE obj)
 
static VALUE rb_stat_z (VALUE obj)
 
static VALUE rb_stat_s (VALUE obj)
 
static VALUE rb_stat_suid (VALUE obj)
 
static VALUE rb_stat_sgid (VALUE obj)
 
static VALUE rb_stat_sticky (VALUE obj)
 
void rb_file_const (const char *name, VALUE value)
 
int rb_is_absolute_path (const char *path)
 
static int path_check_0 (VALUE path, int execpath)
 
int rb_path_check (const char *path)
 
int ruby_is_fd_loadable (int fd)
 
int rb_file_load_ok (const char *path)
 
static int is_explicit_relative (const char *path)
 
static VALUE copy_path_class (VALUE path, VALUE orig)
 
int rb_find_file_ext (VALUE *filep, const char *const *ext)
 
int rb_find_file_ext_safe (VALUE *filep, const char *const *ext, int safe_level)
 
VALUE rb_find_file (VALUE path)
 
VALUE rb_find_file_safe (VALUE path, int safe_level)
 
static void define_filetest_function (const char *name, VALUE(*func)(ANYARGS), int argc)
 
void Init_File (void)
 

Variables

VALUE rb_cFile
 
VALUE rb_mFileTest
 
VALUE rb_cStat
 
static const rb_data_type_t stat_data_type
 
static VALUE separator
 
VALUE rb_mFConst
 
static const char null_device []
 

Macro Definition Documentation

◆ apply2args

#define apply2args (   n)    (rb_check_arity(argc, n, UNLIMITED_ARGUMENTS), argc-=n)

◆ BUFCHECK

#define BUFCHECK (   cond)
Value:
do {\
bdiff = p - buf;\
if (cond) {\
do {buflen *= 2;} while (cond);\
rb_str_resize(result, buflen);\
p = buf + bdiff;\
pend = buf + buflen;\
}\
} while (0)
#define cond(node)
Definition: ripper.c:464
unsigned char buf[MIME_BUF_SIZE]
Definition: nkf.c:4309
static VALUE result
Definition: nkf.c:40
#define RSTRING_PTR(str)
Definition: ruby.h:982

Definition at line 3133 of file file.c.

Referenced by rb_file_expand_path_internal().

◆ BUFCOPY

#define BUFCOPY (   srcptr,
  srclen 
)
Value:
do { \
const int skip = SKIPPATHSEP(p); \
rb_str_set_len(result, p-buf+skip); \
BUFCHECK(bdiff + ((srclen)+skip) >= buflen); \
p += skip; \
memcpy(p, (srcptr), (srclen)); \
p += (srclen); \
} while (0)
#define SKIPPATHSEP(p)
Definition: file.c:3152
unsigned char buf[MIME_BUF_SIZE]
Definition: nkf.c:4309
static VALUE result
Definition: nkf.c:40

Definition at line 3155 of file file.c.

Referenced by rb_file_expand_path_internal().

◆ BUFINIT

#define BUFINIT ( )
Value:
(\
buflen = RSTRING_LEN(result),\
pend = p + buflen)
#define RSTRING_LEN(str)
Definition: ruby.h:978
unsigned char buf[MIME_BUF_SIZE]
Definition: nkf.c:4309
static VALUE result
Definition: nkf.c:40
#define RSTRING_PTR(str)
Definition: ruby.h:982

Definition at line 3144 of file file.c.

Referenced by rb_file_expand_path_internal().

◆ CHECK

#define CHECK (   n)    test_check((n), argc, argv)

Definition at line 4703 of file file.c.

Referenced by rb_f_test().

◆ check_expand_path_args

#define check_expand_path_args (   fname,
  dname 
)
Value:
(((fname) = rb_get_path(fname)), \
(void)(NIL_P(dname) ? (dname) : ((dname) = rb_get_path(dname))))
VALUE rb_get_path(VALUE obj)
Definition: file.c:217
#define NIL_P(v)
Definition: ruby.h:451

Definition at line 3675 of file file.c.

Referenced by rb_file_absolute_path(), and rb_file_expand_path().

◆ DEVT2NUM

#define DEVT2NUM (   v)    UINT2NUM(v)

◆ ENABLE_PATH_CHECK

#define ENABLE_PATH_CHECK   1

Definition at line 5609 of file file.c.

◆ endpwent

#define endpwent ( )    ((void)0)

◆ expand_path

#define expand_path (   fname,
  dname,
  abs_mode,
  long_name,
  result 
)    str_shrink(rb_file_expand_path_internal(fname, dname, abs_mode, long_name, result))

Definition at line 3672 of file file.c.

Referenced by rb_file_absolute_path(), rb_file_expand_path(), and rb_file_expand_path_fast().

◆ EXPAND_PATH_BUFFER

#define EXPAND_PATH_BUFFER ( )    rb_usascii_str_new(0, MAXPATHLEN + 2)

◆ fncomp

#define fncomp   strncmp

Referenced by rmext().

◆ fpath_check

#define fpath_check (   path)    path_check_0((path), FALSE)

Definition at line 5664 of file file.c.

Referenced by rb_find_file_ext_safe(), and rb_find_file_safe().

◆ has_unc

#define has_unc (   buf)    0

Definition at line 2950 of file file.c.

◆ HAVE_STAT_BIRTHTIME

#define HAVE_STAT_BIRTHTIME

Definition at line 831 of file file.c.

◆ Inc

#define Inc (   p,
  e,
  enc 
)    ((p) = Next((p), (e), (enc)))

◆ insecure_obj_p

#define insecure_obj_p (   obj,
  level 
)    ((level) > 0 && OBJ_TAINTED(obj))

Definition at line 133 of file file.c.

Referenced by rb_get_path_check_convert(), and rb_get_path_check_to_string().

◆ isADS

#define isADS (   x)    0

Definition at line 2941 of file file.c.

Referenced by rb_enc_path_end(), rb_file_expand_path_internal(), and ruby_enc_find_extname().

◆ isdirsep

#define isdirsep (   x)    ((x) == '/')

◆ istrailinggarbage

#define istrailinggarbage (   x)    0

Definition at line 2936 of file file.c.

Referenced by rb_enc_path_end(), rb_file_expand_path_internal(), and ruby_enc_find_extname().

◆ LOCK_EX

#define LOCK_EX   2

Definition at line 4572 of file file.c.

Referenced by flock_winnt(), and Init_File().

◆ LOCK_NB

#define LOCK_NB   4

Definition at line 4575 of file file.c.

Referenced by flock_winnt(), Init_File(), and rb_file_flock().

◆ LOCK_SH

#define LOCK_SH   1

Definition at line 4569 of file file.c.

Referenced by flock_winnt(), and Init_File().

◆ LOCK_UN

#define LOCK_UN   8

Definition at line 4578 of file file.c.

Referenced by flock_winnt(), and Init_File().

◆ lstat

#define lstat   stat

◆ MAXPATHLEN

#define MAXPATHLEN   1024

◆ Next

#define Next (   p,
  e,
  enc 
)    ((p) + rb_enc_mbclen((p), (e), (enc)))

Definition at line 2944 of file file.c.

◆ nextdirsep

#define nextdirsep   rb_enc_path_next

Definition at line 3018 of file file.c.

Referenced by rb_file_expand_path_internal().

◆ NORMALIZE_UTF8PATH

#define NORMALIZE_UTF8PATH   0

Definition at line 343 of file file.c.

Referenced by append_fspath().

◆ NUM2DEVT

#define NUM2DEVT (   v)    NUM2UINT(v)

Definition at line 467 of file file.c.

Referenced by rb_stat_inspect().

◆ O_BINARY

#define O_BINARY   0

Referenced by Init_File().

◆ O_SHARE_DELETE

#define O_SHARE_DELETE   0

Referenced by Init_File(), and w32_wopen().

◆ PRI_DEVT_PREFIX

#define PRI_DEVT_PREFIX   ""

Definition at line 473 of file file.c.

Referenced by rb_stat_inspect().

◆ rb_file_birthtime

#define rb_file_birthtime   rb_f_notimplement

Definition at line 2254 of file file.c.

Referenced by Init_File().

◆ rb_file_s_birthtime

#define rb_file_s_birthtime   rb_f_notimplement

Definition at line 2225 of file file.c.

Referenced by Init_File(), and rb_file_ctime().

◆ rb_file_s_lchmod

#define rb_file_s_lchmod   rb_f_notimplement

Definition at line 2387 of file file.c.

Referenced by Init_File(), and rb_file_chmod().

◆ rb_file_s_lchown

#define rb_file_s_lchown   rb_f_notimplement

Definition at line 2521 of file file.c.

Referenced by Init_File(), and rb_file_chown().

◆ rb_file_s_link

#define rb_file_s_link   rb_f_notimplement

Definition at line 2720 of file file.c.

Referenced by Init_File(), and syserr_fail2_in().

◆ rb_file_s_mkfifo

#define rb_file_s_mkfifo   rb_f_notimplement

Definition at line 5579 of file file.c.

Referenced by Init_File(), and rb_stat_sticky().

◆ rb_file_s_readlink

#define rb_file_s_readlink   rb_f_notimplement

Definition at line 2802 of file file.c.

Referenced by Init_File().

◆ rb_file_s_symlink

#define rb_file_s_symlink   rb_f_notimplement

Definition at line 2750 of file file.c.

Referenced by Init_File().

◆ rb_file_s_truncate

#define rb_file_s_truncate   rb_f_notimplement

Definition at line 4518 of file file.c.

Referenced by Init_File(), and rb_file_s_join().

◆ rb_file_truncate

#define rb_file_truncate   rb_f_notimplement

Definition at line 4565 of file file.c.

Referenced by Init_File().

◆ rb_stat_birthtime

#define rb_stat_birthtime   rb_f_notimplement

Definition at line 927 of file file.c.

Referenced by Init_File(), rb_stat_ctime(), and rb_stat_inspect().

◆ S_IRUGO

#define S_IRUGO   (S_IRUSR | S_IRGRP | S_IROTH)

◆ S_ISBLK

#define S_ISBLK (   m)    (0) /* anytime false */

◆ S_ISCHR

#define S_ISCHR (   m)    (((m) & S_IFMT) == S_IFCHR)

◆ S_ISDIR

#define S_ISDIR (   m)    (((m) & S_IFMT) == S_IFDIR)

◆ S_ISREG

#define S_ISREG (   m)    (((m) & S_IFMT) == S_IFREG)

Definition at line 1713 of file file.c.

Referenced by rb_file_file_p(), rb_file_ftype(), rb_stat_f(), and ruby_is_fd_loadable().

◆ S_IWOTH

#define S_IWOTH   002

◆ S_IWUGO

#define S_IWUGO   (S_IWUSR | S_IWGRP | S_IWOTH)

◆ S_IXUGO

#define S_IXUGO   (S_IXUSR | S_IXGRP | S_IXOTH)

◆ SKIPPATHSEP

#define SKIPPATHSEP (   p)    1

Definition at line 3152 of file file.c.

◆ skipprefix

#define skipprefix (   path,
  end,
  enc 
)    (path)

◆ ST2UINT

#define ST2UINT (   val)    ((val) & ~(~1UL << (sizeof(val) * CHAR_BIT - 1)))

Definition at line 464 of file file.c.

Referenced by rb_stat_mode().

◆ STAT

#define STAT (   p,
 
)    stat((p), (s))

Definition at line 126 of file file.c.

Referenced by eaccess(), path_check_0(), rb_file_grpowned_p(), rb_stat(), and rb_stat_init().

◆ strrdirsep

#define strrdirsep   rb_enc_path_last_separator

◆ sys_fail2

#define sys_fail2 (   s1,
  s2 
)    syserr_fail2(errno, s1, s2)

Definition at line 2666 of file file.c.

Referenced by syserr_fail2_in().

◆ syserr_fail2_in

#define syserr_fail2_in (   func,
  e,
  s1,
  s2 
)    syserr_fail2(e, s1, s2)

Definition at line 2664 of file file.c.

◆ USE_NTFS

#define USE_NTFS   0

Definition at line 2922 of file file.c.

◆ USE_NTFS_ADS

#define USE_NTFS_ADS   0

Definition at line 2929 of file file.c.

◆ utime_failed

#define utime_failed (   path,
  tsp,
  atime,
  mtime 
)    rb_sys_fail_path(path)

Definition at line 2564 of file file.c.

Referenced by utime_internal().

◆ WITH_ROOTDIFF

#define WITH_ROOTDIFF (   stmt)
Value:
do { \
long rootdiff = root - buf; \
stmt; \
root = buf + rootdiff; \
} while (0)
unsigned char buf[MIME_BUF_SIZE]
Definition: nkf.c:4309

Definition at line 3164 of file file.c.

Referenced by rb_file_expand_path_internal().

Function Documentation

◆ append_fspath()

static char* append_fspath ( VALUE  result,
VALUE  fname,
char *  dir,
rb_encoding **  enc,
rb_encoding fsenc 
)
static

◆ apply2files()

static VALUE apply2files ( void(*)(const char *, VALUE, void *)  func,
int  argc,
VALUE argv,
void *  arg 
)
static

◆ check_path_encoding()

static rb_encoding* check_path_encoding ( VALUE  str)
static

◆ chmod_internal()

static void chmod_internal ( const char *  path,
VALUE  pathv,
void *  mode 
)
static

Definition at line 2284 of file file.c.

References rb_sys_fail_path.

Referenced by rb_file_s_chmod().

◆ chompdirsep()

static char* chompdirsep ( const char *  path,
const char *  end,
rb_encoding enc 
)
static

◆ chown_internal()

static void chown_internal ( const char *  path,
VALUE  pathv,
void *  arg 
)
static

Definition at line 2414 of file file.c.

References chown(), chown_args::group, chown_args::owner, and rb_sys_fail_path.

Referenced by rb_file_s_chown().

◆ copy_home_path()

static VALUE copy_home_path ( VALUE  result,
const char *  dir 
)
static

◆ copy_path_class()

static VALUE copy_path_class ( VALUE  path,
VALUE  orig 
)
static

Definition at line 5756 of file file.c.

References OBJ_FREEZE, rb_obj_class(), RBASIC_SET_CLASS, and str_shrink().

Referenced by rb_find_file_ext_safe(), and rb_find_file_safe().

◆ define_filetest_function()

static void define_filetest_function ( const char *  name,
VALUE(*)(ANYARGS func,
int  argc 
)
static

Definition at line 5900 of file file.c.

References func, rb_cFile, rb_define_module_function(), rb_define_singleton_method(), and rb_mFileTest.

Referenced by Init_File().

◆ eaccess()

int eaccess ( const char *  path,
int  mode 
)

◆ file_expand_path_1()

static VALUE file_expand_path_1 ( VALUE  fname)
static

Definition at line 3680 of file file.c.

References EXPAND_PATH_BUFFER, Qnil, and rb_file_expand_path_internal().

Referenced by rb_find_file_ext_safe(), and rb_find_file_safe().

◆ file_inspect_join()

static VALUE file_inspect_join ( VALUE  ary,
VALUE  argp,
int  recur 
)
static

Definition at line 4365 of file file.c.

References rb_eArgError, rb_file_join(), and rb_raise().

Referenced by rb_file_join().

◆ file_path_convert()

static VALUE file_path_convert ( VALUE  name)
static

◆ flock()

int flock ( int  ,
int   
)

Definition at line 125 of file flock.c.

Referenced by ioctl_narg_len(), and rb_thread_flock().

◆ get_stat()

static struct stat* get_stat ( VALUE  self)
static

◆ Init_File()

void Init_File ( void  )

Definition at line 5953 of file file.c.

References define_filetest_function(), INT2FIX, LOCK_EX, LOCK_NB, LOCK_SH, LOCK_UN, O_BINARY, O_NONBLOCK, O_SHARE_DELETE, PATH_SEP, Qnil, rb_cFile, rb_cIO, rb_cObject, rb_cStat, rb_define_alloc_func(), rb_define_class(), rb_define_class_under(), rb_define_const(), rb_define_global_function(), rb_define_method(), rb_define_module(), rb_define_module_under(), rb_define_singleton_method(), rb_f_test(), rb_file_atime(), rb_file_birthtime, rb_file_blockdev_p(), rb_file_chardev_p(), rb_file_chmod(), rb_file_chown(), rb_file_ctime(), rb_file_directory_p(), rb_file_executable_p(), rb_file_executable_real_p(), rb_file_exist_p(), rb_file_exists_p(), rb_file_file_p(), rb_file_flock(), rb_file_grpowned_p(), rb_file_identical_p(), rb_file_lstat(), rb_file_mtime(), rb_file_owned_p(), rb_file_path(), rb_file_pipe_p(), rb_file_readable_p(), rb_file_readable_real_p(), rb_file_s_absolute_path(), rb_file_s_atime(), rb_file_s_basename(), rb_file_s_birthtime, rb_file_s_chmod(), rb_file_s_chown(), rb_file_s_ctime(), rb_file_s_dirname(), rb_file_s_expand_path(), rb_file_s_extname(), rb_file_s_ftype(), rb_file_s_join(), rb_file_s_lchmod, rb_file_s_lchown, rb_file_s_link, rb_file_s_lstat(), rb_file_s_mkfifo, rb_file_s_mtime(), rb_file_s_path(), rb_file_s_readlink, rb_file_s_realdirpath(), rb_file_s_realpath(), rb_file_s_rename(), rb_file_s_size(), rb_file_s_split(), rb_file_s_stat(), rb_file_s_symlink, rb_file_s_truncate, rb_file_s_umask(), rb_file_s_unlink(), rb_file_s_utime(), rb_file_sgid_p(), rb_file_size(), rb_file_size_p(), rb_file_socket_p(), rb_file_sticky_p(), rb_file_suid_p(), rb_file_symlink_p(), rb_file_truncate, rb_file_world_readable_p(), rb_file_world_writable_p(), rb_file_writable_p(), rb_file_writable_real_p(), rb_file_zero_p(), rb_include_module(), rb_io_stat(), rb_mComparable, rb_mFileTest, rb_obj_freeze(), rb_stat_atime(), rb_stat_b(), rb_stat_birthtime, rb_stat_blksize(), rb_stat_blocks(), rb_stat_c(), rb_stat_cmp(), rb_stat_ctime(), rb_stat_d(), rb_stat_dev(), rb_stat_dev_major(), rb_stat_dev_minor(), rb_stat_f(), rb_stat_ftype(), rb_stat_gid(), rb_stat_grpowned(), rb_stat_init(), rb_stat_init_copy(), rb_stat_ino(), rb_stat_inspect(), rb_stat_l(), rb_stat_mode(), rb_stat_mtime(), rb_stat_nlink(), rb_stat_owned(), rb_stat_p(), rb_stat_r(), rb_stat_R(), rb_stat_rdev(), rb_stat_rdev_major(), rb_stat_rdev_minor(), rb_stat_S(), rb_stat_s(), rb_stat_s_alloc(), rb_stat_sgid(), rb_stat_size(), rb_stat_sticky(), rb_stat_suid(), rb_stat_uid(), rb_stat_w(), rb_stat_W(), rb_stat_wr(), rb_stat_ww(), rb_stat_x(), rb_stat_X(), rb_stat_z(), rb_str_new2, and rb_usascii_str_new2.

Referenced by Init_IO().

◆ is_explicit_relative()

static int is_explicit_relative ( const char *  path)
static

Definition at line 5748 of file file.c.

References isdirsep.

Referenced by rb_find_file_ext_safe(), and rb_find_file_safe().

◆ NORETURN()

NORETURN ( static void   syserr_fail2_inconst char *, int, VALUE, VALUE)

◆ ospath_new()

static VALUE ospath_new ( const char *  ptr,
long  len,
rb_encoding fsenc 
)
static

Definition at line 3268 of file file.c.

References rb_enc_associate(), and rb_enc_str_new().

Referenced by append_fspath().

◆ path_check_0()

static int path_check_0 ( VALUE  path,
int  execpath 
)
static

◆ rb_default_home_dir()

VALUE rb_default_home_dir ( VALUE  result)

Definition at line 3238 of file file.c.

Referenced by dir_s_home(), and rb_file_expand_path_internal().

◆ rb_enc_path_end()

char* rb_enc_path_end ( const char *  path,
const char *  end,
rb_encoding enc 
)

Definition at line 3102 of file file.c.

References chompdirsep(), Inc, isADS, isdirsep, istrailinggarbage, and last.

Referenced by check_dirname().

◆ rb_enc_path_last_separator()

char* rb_enc_path_last_separator ( const char *  path,
const char *  end,
rb_encoding enc 
)

Definition at line 3068 of file file.c.

References Inc, isdirsep, last, and NULL.

Referenced by ruby_init_loadpath_safe().

◆ rb_enc_path_next()

char* rb_enc_path_next ( const char *  s,
const char *  e,
rb_encoding enc 
)

Definition at line 3020 of file file.c.

References Inc, and isdirsep.

Referenced by rb_enc_path_skip_prefix(), and realpath_rec().

◆ rb_enc_path_skip_prefix()

char* rb_enc_path_skip_prefix ( const char *  path,
const char *  end,
rb_encoding enc 
)

Definition at line 3034 of file file.c.

References isdirsep, and rb_enc_path_next().

Referenced by check_dirname(), and ruby_glob0().

◆ rb_f_test()

static VALUE rb_f_test ( int  argc,
VALUE argv 
)
static

◆ rb_file_absolute_path()

VALUE rb_file_absolute_path ( VALUE  fname,
VALUE  dname 
)

Definition at line 3734 of file file.c.

References check_expand_path_args, expand_path, and EXPAND_PATH_BUFFER.

Referenced by rb_f_require_relative(), and rb_file_s_absolute_path().

◆ rb_file_atime()

static VALUE rb_file_atime ( VALUE  obj)
static

Definition at line 2082 of file file.c.

References rb_io_t::fd, fstat, GetOpenFile, rb_io_t::pathv, rb_sys_fail_path, and stat_atime().

Referenced by Init_File().

◆ rb_file_blockdev_p()

static VALUE rb_file_blockdev_p ( VALUE  obj,
VALUE  fname 
)
static

Definition at line 1457 of file file.c.

References Qfalse, Qtrue, rb_stat(), and S_ISBLK.

Referenced by Init_File(), and rb_f_test().

◆ rb_file_chardev_p()

static VALUE rb_file_chardev_p ( VALUE  obj,
VALUE  fname 
)
static

Definition at line 1486 of file file.c.

References Qfalse, Qtrue, rb_stat(), and S_ISCHR.

Referenced by Init_File(), and rb_f_test().

◆ rb_file_chmod()

static VALUE rb_file_chmod ( VALUE  obj,
VALUE  vmode 
)
static

◆ rb_file_chown()

static VALUE rb_file_chown ( VALUE  obj,
VALUE  owner,
VALUE  group 
)
static

◆ rb_file_const()

void rb_file_const ( const char *  name,
VALUE  value 
)

Definition at line 5585 of file file.c.

References rb_define_const().

Referenced by Init_Dir().

◆ rb_file_ctime()

static VALUE rb_file_ctime ( VALUE  obj)
static

◆ rb_file_directory_p()

VALUE rb_file_directory_p ( VALUE  obj,
VALUE  fname 
)

Definition at line 1336 of file file.c.

References Qfalse, Qtrue, rb_stat(), and S_ISDIR.

Referenced by dir_s_home(), Init_Dir(), Init_File(), rb_dir_exists_p(), and rb_f_test().

◆ rb_file_dirname()

VALUE rb_file_dirname ( VALUE  fname)

◆ rb_file_executable_p()

static VALUE rb_file_executable_p ( VALUE  obj,
VALUE  fname 
)
static

Definition at line 1687 of file file.c.

References eaccess(), FilePathValue, Qfalse, Qtrue, rb_str_encode_ospath(), StringValueCStr, and X_OK.

Referenced by Init_File(), and rb_f_test().

◆ rb_file_executable_real_p()

static VALUE rb_file_executable_real_p ( VALUE  obj,
VALUE  fname 
)
static

Definition at line 1704 of file file.c.

References access, FilePathValue, Qfalse, Qtrue, rb_str_encode_ospath(), StringValueCStr, and X_OK.

Referenced by Init_File(), and rb_f_test().

◆ rb_file_exist_p()

static VALUE rb_file_exist_p ( VALUE  obj,
VALUE  fname 
)
static

Definition at line 1512 of file file.c.

References Qfalse, Qtrue, and rb_stat().

Referenced by Init_File(), rb_f_test(), and rb_file_exists_p().

◆ rb_file_exists_p()

static VALUE rb_file_exists_p ( VALUE  obj,
VALUE  fname 
)
static

Definition at line 1527 of file file.c.

References rb_cFile, rb_class_inherited_p(), rb_file_exist_p(), rb_mFileTest, RB_TYPE_P, rb_warning(), RTEST, and T_CLASS.

Referenced by Init_File().

◆ rb_file_expand_path()

VALUE rb_file_expand_path ( VALUE  fname,
VALUE  dname 
)

Definition at line 3686 of file file.c.

References check_expand_path_args, expand_path, and EXPAND_PATH_BUFFER.

Referenced by expand_include_path(), and rb_file_s_expand_path().

◆ rb_file_expand_path_fast()

VALUE rb_file_expand_path_fast ( VALUE  fname,
VALUE  dname 
)

Definition at line 3693 of file file.c.

References expand_path, and EXPAND_PATH_BUFFER.

Referenced by rb_construct_expanded_load_path(), and rb_feature_provided().

◆ rb_file_expand_path_internal()

VALUE rb_file_expand_path_internal ( VALUE  fname,
VALUE  dname,
int  abs_mode,
int  long_name,
VALUE  result 
)

◆ rb_file_file_p()

static VALUE rb_file_file_p ( VALUE  obj,
VALUE  fname 
)
static

Definition at line 1729 of file file.c.

References Qfalse, Qtrue, rb_stat(), and S_ISREG.

Referenced by Init_File(), and rb_f_test().

◆ rb_file_flock()

static VALUE rb_file_flock ( VALUE  obj,
VALUE  operation 
)
static

◆ rb_file_ftype()

static VALUE rb_file_ftype ( const struct stat st)
static

Definition at line 1976 of file file.c.

References rb_usascii_str_new2, S_ISBLK, S_ISCHR, S_ISDIR, S_ISLNK, and S_ISREG.

Referenced by rb_file_s_ftype(), and rb_stat_ftype().

◆ rb_file_grpowned_p()

static VALUE rb_file_grpowned_p ( VALUE  obj,
VALUE  fname 
)
static

Definition at line 1821 of file file.c.

References FilePathValue, Qfalse, Qtrue, rb_group_member(), rb_stat(), rb_str_encode_ospath(), STAT, and StringValueCStr.

Referenced by Init_File(), and rb_f_test().

◆ rb_file_identical_p()

static VALUE rb_file_identical_p ( VALUE  obj,
VALUE  fname1,
VALUE  fname2 
)
static

Definition at line 1917 of file file.c.

References Qfalse, Qtrue, rb_ensure(), and rb_stat().

Referenced by Init_File(), and rb_f_test().

◆ rb_file_join()

static VALUE rb_file_join ( VALUE  ary,
VALUE  sep 
)
static

◆ rb_file_load_ok()

int rb_file_load_ok ( const char *  path)

Definition at line 5724 of file file.c.

Referenced by rb_f_load(), rb_find_file_ext_safe(), and rb_find_file_safe().

◆ rb_file_lstat()

static VALUE rb_file_lstat ( VALUE  obj)
static

◆ rb_file_mtime()

static VALUE rb_file_mtime ( VALUE  obj)
static

Definition at line 2130 of file file.c.

References rb_io_t::fd, fstat, GetOpenFile, rb_io_t::pathv, rb_sys_fail_path, and stat_mtime().

Referenced by Init_File().

◆ rb_file_owned_p()

static VALUE rb_file_owned_p ( VALUE  obj,
VALUE  fname 
)
static

Definition at line 1790 of file file.c.

References geteuid(), Qfalse, Qtrue, and rb_stat().

Referenced by Init_File(), and rb_f_test().

◆ rb_file_path()

static VALUE rb_file_path ( VALUE  obj)
static

◆ rb_file_pipe_p()

static VALUE rb_file_pipe_p ( VALUE  obj,
VALUE  fname 
)
static

Definition at line 1359 of file file.c.

References Qfalse, Qtrue, and rb_stat().

Referenced by Init_File(), and rb_f_test().

◆ rb_file_readable_p()

static VALUE rb_file_readable_p ( VALUE  obj,
VALUE  fname 
)
static

Definition at line 1551 of file file.c.

References eaccess(), FilePathValue, Qfalse, Qtrue, R_OK, rb_str_encode_ospath(), and StringValueCStr.

Referenced by Init_File(), and rb_f_test().

◆ rb_file_readable_real_p()

static VALUE rb_file_readable_real_p ( VALUE  obj,
VALUE  fname 
)
static

Definition at line 1568 of file file.c.

References access, FilePathValue, Qfalse, Qtrue, R_OK, rb_str_encode_ospath(), and StringValueCStr.

Referenced by Init_File(), and rb_f_test().

◆ rb_file_rowned_p()

static VALUE rb_file_rowned_p ( VALUE  obj,
VALUE  fname 
)
static

Definition at line 1800 of file file.c.

References getuid(), Qfalse, Qtrue, and rb_stat().

Referenced by rb_f_test().

◆ rb_file_s_absolute_path()

VALUE rb_file_s_absolute_path ( int  argc,
const VALUE argv 
)

Definition at line 3754 of file file.c.

References Qnil, rb_check_arity, and rb_file_absolute_path().

Referenced by Init_File().

◆ rb_file_s_atime()

static VALUE rb_file_s_atime ( VALUE  klass,
VALUE  fname 
)
static

Definition at line 2058 of file file.c.

References errno, FilePathValue, rb_stat(), rb_syserr_fail_path, and stat_atime().

Referenced by Init_File().

◆ rb_file_s_basename()

static VALUE rb_file_s_basename ( int  argc,
VALUE argv 
)
static

◆ rb_file_s_chmod()

static VALUE rb_file_s_chmod ( int  argc,
VALUE argv 
)
static

Definition at line 2304 of file file.c.

References apply2args, apply2files(), chmod_internal(), and NUM2INT.

Referenced by Init_File().

◆ rb_file_s_chown()

static VALUE rb_file_s_chown ( int  argc,
VALUE argv 
)
static

Definition at line 2437 of file file.c.

References apply2args, apply2files(), chown_internal(), chown_args::group, chown_args::owner, to_gid(), and to_uid().

Referenced by Init_File().

◆ rb_file_s_ctime()

static VALUE rb_file_s_ctime ( VALUE  klass,
VALUE  fname 
)
static

Definition at line 2159 of file file.c.

References errno, FilePathValue, rb_stat(), rb_syserr_fail_path, and stat_ctime().

Referenced by Init_File().

◆ rb_file_s_dirname()

static VALUE rb_file_s_dirname ( VALUE  klass,
VALUE  fname 
)
static

Definition at line 4171 of file file.c.

References rb_file_dirname().

Referenced by Init_File().

◆ rb_file_s_expand_path()

VALUE rb_file_s_expand_path ( int  argc,
const VALUE argv 
)

Definition at line 3727 of file file.c.

References Qnil, rb_check_arity, and rb_file_expand_path().

Referenced by Init_File().

◆ rb_file_s_extname()

static VALUE rb_file_s_extname ( VALUE  klass,
VALUE  fname 
)
static

◆ rb_file_s_ftype()

static VALUE rb_file_s_ftype ( VALUE  klass,
VALUE  fname 
)
static

Definition at line 2032 of file file.c.

References FilePathValue, lstat, rb_file_ftype(), rb_str_encode_ospath(), rb_sys_fail_path, and StringValueCStr.

Referenced by Init_File().

◆ rb_file_s_join()

static VALUE rb_file_s_join ( VALUE  klass,
VALUE  args 
)
static

◆ rb_file_s_lstat()

static VALUE rb_file_s_lstat ( VALUE  klass,
VALUE  fname 
)
static

◆ rb_file_s_mtime()

static VALUE rb_file_s_mtime ( VALUE  klass,
VALUE  fname 
)
static

Definition at line 2107 of file file.c.

References errno, FilePathValue, rb_stat(), rb_syserr_fail_path, and stat_mtime().

Referenced by Init_File().

◆ rb_file_s_path()

static VALUE rb_file_s_path ( VALUE  klass,
VALUE  fname 
)
static

Definition at line 4337 of file file.c.

References rb_get_path().

Referenced by Init_File().

◆ rb_file_s_realdirpath()

static VALUE rb_file_s_realdirpath ( int  argc,
VALUE argv,
VALUE  klass 
)
static

Definition at line 3989 of file file.c.

References FilePathValue, Qnil, rb_check_arity, and rb_realpath_internal().

Referenced by Init_File().

◆ rb_file_s_realpath()

static VALUE rb_file_s_realpath ( int  argc,
VALUE argv,
VALUE  klass 
)
static

Definition at line 3968 of file file.c.

References FilePathValue, Qnil, rb_check_arity, and rb_realpath_internal().

Referenced by Init_File().

◆ rb_file_s_rename()

static VALUE rb_file_s_rename ( VALUE  klass,
VALUE  from,
VALUE  to 
)
static

Definition at line 2839 of file file.c.

References errno, f, FilePathValue, INT2FIX, rb_str_encode_ospath(), and StringValueCStr.

Referenced by Init_File().

◆ rb_file_s_size()

static VALUE rb_file_s_size ( VALUE  klass,
VALUE  fname 
)
static

Definition at line 1963 of file file.c.

References errno, FilePathValue, OFFT2NUM, rb_stat(), and rb_syserr_fail_path.

Referenced by Init_File().

◆ rb_file_s_split()

static VALUE rb_file_s_split ( VALUE  klass,
VALUE  path 
)
static

Definition at line 4354 of file file.c.

References FilePathStringValue, rb_assoc_new(), rb_file_dirname(), and rb_file_s_basename().

Referenced by Init_File().

◆ rb_file_s_stat()

static VALUE rb_file_s_stat ( VALUE  klass,
VALUE  fname 
)
static

Definition at line 1097 of file file.c.

References FilePathValue, rb_stat(), rb_stat_new(), and rb_sys_fail_path.

Referenced by Init_File(), and rb_file_s_lstat().

◆ rb_file_s_umask()

static VALUE rb_file_s_umask ( int  argc,
VALUE argv 
)
static

Definition at line 2886 of file file.c.

References INT2FIX, NUM2INT, rb_check_arity, and umask().

Referenced by Init_File().

◆ rb_file_s_unlink()

static VALUE rb_file_s_unlink ( int  argc,
VALUE argv,
VALUE  klass 
)
static

Definition at line 2823 of file file.c.

References apply2files(), and unlink_internal().

Referenced by Init_File().

◆ rb_file_s_utime()

static VALUE rb_file_s_utime ( int  argc,
VALUE argv 
)
static

◆ rb_file_sgid_p()

static VALUE rb_file_sgid_p ( VALUE  obj,
VALUE  fname 
)
static

Definition at line 1871 of file file.c.

References Qfalse.

Referenced by Init_File(), and rb_f_test().

◆ rb_file_size()

static VALUE rb_file_size ( VALUE  obj)
static

◆ rb_file_size_p()

static VALUE rb_file_size_p ( VALUE  obj,
VALUE  fname 
)
static

Definition at line 1769 of file file.c.

References OFFT2NUM, Qnil, and rb_stat().

Referenced by Init_File(), and rb_f_test().

◆ rb_file_socket_p()

static VALUE rb_file_socket_p ( VALUE  obj,
VALUE  fname 
)
static

Definition at line 1421 of file file.c.

References Qfalse, Qtrue, and rb_stat().

Referenced by Init_File(), and rb_f_test().

◆ rb_file_sticky_p()

static VALUE rb_file_sticky_p ( VALUE  obj,
VALUE  fname 
)
static

Definition at line 1888 of file file.c.

References Qnil.

Referenced by Init_File(), and rb_f_test().

◆ rb_file_suid_p()

static VALUE rb_file_suid_p ( VALUE  obj,
VALUE  fname 
)
static

Definition at line 1854 of file file.c.

References Qfalse.

Referenced by Init_File(), and rb_f_test().

◆ rb_file_symlink_p()

static VALUE rb_file_symlink_p ( VALUE  obj,
VALUE  fname 
)
static

Definition at line 1383 of file file.c.

References FilePathValue, lstat, Qfalse, Qtrue, rb_str_encode_ospath(), S_ISLNK, and StringValueCStr.

Referenced by Init_File(), and rb_f_test().

◆ rb_file_world_readable_p()

static VALUE rb_file_world_readable_p ( VALUE  obj,
VALUE  fname 
)
static

Definition at line 1601 of file file.c.

References Qnil, rb_stat(), S_IROTH, S_IRUGO, S_IWUGO, S_IXUGO, and UINT2NUM.

Referenced by Init_File().

◆ rb_file_world_writable_p()

static VALUE rb_file_world_writable_p ( VALUE  obj,
VALUE  fname 
)
static

Definition at line 1665 of file file.c.

References Qnil, rb_stat(), S_IRUGO, S_IWOTH, S_IWUGO, S_IXUGO, and UINT2NUM.

Referenced by Init_File().

◆ rb_file_writable_p()

static VALUE rb_file_writable_p ( VALUE  obj,
VALUE  fname 
)
static

Definition at line 1623 of file file.c.

References eaccess(), FilePathValue, Qfalse, Qtrue, rb_str_encode_ospath(), StringValueCStr, and W_OK.

Referenced by Init_File(), and rb_f_test().

◆ rb_file_writable_real_p()

static VALUE rb_file_writable_real_p ( VALUE  obj,
VALUE  fname 
)
static

Definition at line 1640 of file file.c.

References access, FilePathValue, Qfalse, Qtrue, rb_str_encode_ospath(), StringValueCStr, and W_OK.

Referenced by Init_File(), and rb_f_test().

◆ rb_file_zero_p()

static VALUE rb_file_zero_p ( VALUE  obj,
VALUE  fname 
)
static

Definition at line 1749 of file file.c.

References Qfalse, Qtrue, and rb_stat().

Referenced by Init_File(), and rb_f_test().

◆ rb_find_file()

VALUE rb_find_file ( VALUE  path)

Definition at line 5837 of file file.c.

References rb_find_file_safe(), and rb_safe_level().

Referenced by file_to_load(), and rb_f_load().

◆ rb_find_file_ext()

int rb_find_file_ext ( VALUE filep,
const char *const ext 
)

Definition at line 5765 of file file.c.

References rb_find_file_ext_safe(), and rb_safe_level().

◆ rb_find_file_ext_safe()

int rb_find_file_ext_safe ( VALUE filep,
const char *const ext,
int  safe_level 
)

◆ rb_find_file_safe()

VALUE rb_find_file_safe ( VALUE  path,
int  safe_level 
)

◆ rb_get_path()

VALUE rb_get_path ( VALUE  obj)

Definition at line 217 of file file.c.

References rb_get_path_check(), and rb_safe_level().

Referenced by apply2files(), rb_feature_provided(), and rb_file_s_path().

◆ rb_get_path_check()

static VALUE rb_get_path_check ( VALUE  obj,
int  level 
)
static

◆ rb_get_path_check_convert()

VALUE rb_get_path_check_convert ( VALUE  obj,
VALUE  tmp,
int  level 
)

◆ rb_get_path_check_to_string()

VALUE rb_get_path_check_to_string ( VALUE  obj,
int  level 
)

◆ rb_get_path_no_checksafe()

VALUE rb_get_path_no_checksafe ( VALUE  obj)

Definition at line 211 of file file.c.

References rb_get_path_check().

◆ rb_group_member()

static int rb_group_member ( GETGROUPS_T  gid)
static

◆ rb_home_dir_of()

VALUE rb_home_dir_of ( VALUE  user,
VALUE  result 
)

◆ rb_io_stat()

static VALUE rb_io_stat ( VALUE  obj)
static

Definition at line 1124 of file file.c.

References rb_io_t::fd, fstat, GetOpenFile, rb_io_t::pathv, rb_stat_new(), and rb_sys_fail_path.

Referenced by Init_File(), and rb_file_lstat().

◆ rb_is_absolute_path()

int rb_is_absolute_path ( const char *  path)

◆ rb_path_check()

int rb_path_check ( const char *  path)

Definition at line 5670 of file file.c.

References path_check_0(), PATH_SEP_CHAR, rb_str_new(), strchr(), strlen(), and TRUE.

Referenced by path_tainted_p().

◆ rb_realpath_internal()

VALUE rb_realpath_internal ( VALUE  basedir,
VALUE  path,
int  strict 
)

◆ rb_stat()

static int rb_stat ( VALUE  file,
struct stat st 
)
static

◆ rb_stat_atime()

static VALUE rb_stat_atime ( VALUE  self)
static

Definition at line 857 of file file.c.

References get_stat(), and stat_atime().

Referenced by Init_File(), and rb_stat_inspect().

◆ rb_stat_b()

static VALUE rb_stat_b ( VALUE  obj)
static

Definition at line 5096 of file file.c.

References get_stat(), Qfalse, Qtrue, and S_ISBLK.

Referenced by Init_File().

◆ rb_stat_blksize()

static VALUE rb_stat_blksize ( VALUE  self)
static

Definition at line 725 of file file.c.

References get_stat(), Qnil, and ULONG2NUM.

Referenced by Init_File(), and rb_stat_inspect().

◆ rb_stat_blocks()

static VALUE rb_stat_blocks ( VALUE  self)
static

Definition at line 746 of file file.c.

References get_stat(), Qnil, and ULONG2NUM.

Referenced by Init_File(), and rb_stat_inspect().

◆ rb_stat_c()

static VALUE rb_stat_c ( VALUE  obj)
static

Definition at line 5118 of file file.c.

References get_stat(), Qfalse, Qtrue, and S_ISCHR.

Referenced by Init_File().

◆ rb_stat_cmp()

static VALUE rb_stat_cmp ( VALUE  self,
VALUE  other 
)
static

◆ rb_stat_ctime()

static VALUE rb_stat_ctime ( VALUE  self)
static

Definition at line 893 of file file.c.

References get_stat(), rb_stat_birthtime, and stat_ctime().

Referenced by Init_File(), and rb_stat_inspect().

◆ rb_stat_d()

static VALUE rb_stat_d ( VALUE  obj)
static

Definition at line 5010 of file file.c.

References get_stat(), Qfalse, Qtrue, and S_ISDIR.

Referenced by Init_File().

◆ rb_stat_dev()

static VALUE rb_stat_dev ( VALUE  self)
static

Definition at line 487 of file file.c.

References DEVT2NUM, and get_stat().

Referenced by Init_File(), and rb_stat_inspect().

◆ rb_stat_dev_major()

static VALUE rb_stat_dev_major ( VALUE  self)
static

Definition at line 504 of file file.c.

References DEVT2NUM, get_stat(), and Qnil.

Referenced by Init_File().

◆ rb_stat_dev_minor()

static VALUE rb_stat_dev_minor ( VALUE  self)
static

Definition at line 525 of file file.c.

References DEVT2NUM, get_stat(), and Qnil.

Referenced by Init_File().

◆ rb_stat_f()

static VALUE rb_stat_f ( VALUE  obj)
static

Definition at line 5439 of file file.c.

References get_stat(), Qfalse, Qtrue, and S_ISREG.

Referenced by Init_File().

◆ rb_stat_ftype()

static VALUE rb_stat_ftype ( VALUE  obj)
static

Definition at line 4993 of file file.c.

References get_stat(), and rb_file_ftype().

Referenced by Init_File().

◆ rb_stat_gid()

static VALUE rb_stat_gid ( VALUE  self)
static

Definition at line 629 of file file.c.

References get_stat(), and GIDT2NUM.

Referenced by Init_File(), and rb_stat_inspect().

◆ rb_stat_grpowned()

static VALUE rb_stat_grpowned ( VALUE  obj)
static

Definition at line 5164 of file file.c.

References get_stat(), Qfalse, Qtrue, and rb_group_member().

Referenced by Init_File(), rb_stat_r(), rb_stat_w(), and rb_stat_x().

◆ rb_stat_init()

static VALUE rb_stat_init ( VALUE  obj,
VALUE  fname 
)
static

Definition at line 4938 of file file.c.

References ALLOC, DATA_PTR, FilePathValue, NULL, Qnil, rb_str_encode_ospath(), rb_sys_fail_path, STAT, StringValueCStr, and xfree().

Referenced by Init_File().

◆ rb_stat_init_copy()

static VALUE rb_stat_init_copy ( VALUE  copy,
VALUE  orig 
)
static

Definition at line 4960 of file file.c.

References ALLOC, DATA_PTR, OBJ_INIT_COPY, and xfree().

Referenced by Init_File().

◆ rb_stat_ino()

static VALUE rb_stat_ino ( VALUE  self)
static

Definition at line 545 of file file.c.

References get_stat(), and ULONG2NUM.

Referenced by Init_File(), and rb_stat_inspect().

◆ rb_stat_inspect()

static VALUE rb_stat_inspect ( VALUE  self)
static

◆ rb_stat_l()

static VALUE rb_stat_l ( VALUE  obj)
static

Definition at line 5052 of file file.c.

References get_stat(), Qfalse, Qtrue, and S_ISLNK.

Referenced by Init_File().

◆ rb_stat_mode()

static VALUE rb_stat_mode ( VALUE  self)
static

Definition at line 579 of file file.c.

References get_stat(), ST2UINT, and UINT2NUM.

Referenced by Init_File(), and rb_stat_inspect().

◆ rb_stat_mtime()

static VALUE rb_stat_mtime ( VALUE  self)
static

Definition at line 873 of file file.c.

References get_stat(), and stat_mtime().

Referenced by Init_File(), and rb_stat_inspect().

◆ rb_stat_new()

VALUE rb_stat_new ( const struct stat st)

Definition at line 416 of file file.c.

References rb_cStat, stat, and stat_new_0().

Referenced by rb_file_lstat(), rb_file_s_lstat(), rb_file_s_stat(), and rb_io_stat().

◆ rb_stat_nlink()

static VALUE rb_stat_nlink ( VALUE  self)
static

Definition at line 597 of file file.c.

References get_stat(), and UINT2NUM.

Referenced by Init_File(), and rb_stat_inspect().

◆ rb_stat_owned()

static VALUE rb_stat_owned ( VALUE  obj)
static

Definition at line 5138 of file file.c.

References get_stat(), geteuid(), Qfalse, and Qtrue.

Referenced by Init_File(), rb_stat_r(), rb_stat_w(), and rb_stat_x().

◆ rb_stat_p()

static VALUE rb_stat_p ( VALUE  obj)
static

Definition at line 5025 of file file.c.

References get_stat(), Qfalse, and Qtrue.

Referenced by Init_File().

◆ rb_stat_r()

static VALUE rb_stat_r ( VALUE  obj)
static

Definition at line 5184 of file file.c.

References get_stat(), geteuid(), Qfalse, Qtrue, rb_stat_grpowned(), rb_stat_owned(), S_IRGRP, S_IROTH, and S_IRUSR.

Referenced by Init_File().

◆ rb_stat_R()

static VALUE rb_stat_R ( VALUE  obj)
static

Definition at line 5217 of file file.c.

References get_stat(), getuid(), Qfalse, Qtrue, rb_group_member(), rb_stat_rowned(), S_IRGRP, S_IROTH, and S_IRUSR.

Referenced by Init_File().

◆ rb_stat_rdev()

static VALUE rb_stat_rdev ( VALUE  self)
static

Definition at line 647 of file file.c.

References DEVT2NUM, get_stat(), and Qnil.

Referenced by Init_File(), and rb_stat_inspect().

◆ rb_stat_rdev_major()

static VALUE rb_stat_rdev_major ( VALUE  self)
static

Definition at line 668 of file file.c.

References DEVT2NUM, get_stat(), and Qnil.

Referenced by Init_File().

◆ rb_stat_rdev_minor()

static VALUE rb_stat_rdev_minor ( VALUE  self)
static

Definition at line 689 of file file.c.

References DEVT2NUM, get_stat(), and Qnil.

Referenced by Init_File().

◆ rb_stat_rowned()

static VALUE rb_stat_rowned ( VALUE  obj)
static

Definition at line 5145 of file file.c.

References get_stat(), getuid(), Qfalse, and Qtrue.

Referenced by rb_stat_R(), rb_stat_W(), and rb_stat_X().

◆ rb_stat_S()

static VALUE rb_stat_S ( VALUE  obj)
static

Definition at line 5073 of file file.c.

References get_stat(), Qfalse, and Qtrue.

Referenced by Init_File().

◆ rb_stat_s()

static VALUE rb_stat_s ( VALUE  obj)
static

Definition at line 5474 of file file.c.

References get_stat(), off_t, OFFT2NUM, Qnil, and size.

Referenced by Init_File().

◆ rb_stat_s_alloc()

static VALUE rb_stat_s_alloc ( VALUE  klass)
static

Definition at line 4923 of file file.c.

References stat_new_0().

Referenced by Init_File().

◆ rb_stat_sgid()

static VALUE rb_stat_sgid ( VALUE  obj)
static

Definition at line 5515 of file file.c.

References get_stat(), Qfalse, and Qtrue.

Referenced by Init_File().

◆ rb_stat_size()

static VALUE rb_stat_size ( VALUE  self)
static

Definition at line 708 of file file.c.

References get_stat(), and OFFT2NUM.

Referenced by Init_File(), and rb_stat_inspect().

◆ rb_stat_sticky()

static VALUE rb_stat_sticky ( VALUE  obj)
static

◆ rb_stat_suid()

static VALUE rb_stat_suid ( VALUE  obj)
static

Definition at line 5494 of file file.c.

References get_stat(), Qfalse, and Qtrue.

Referenced by Init_File().

◆ rb_stat_uid()

static VALUE rb_stat_uid ( VALUE  self)
static

Definition at line 613 of file file.c.

References get_stat(), and UIDT2NUM.

Referenced by Init_File(), and rb_stat_inspect().

◆ rb_stat_w()

static VALUE rb_stat_w ( VALUE  obj)
static

Definition at line 5277 of file file.c.

References get_stat(), geteuid(), Qfalse, Qtrue, rb_stat_grpowned(), rb_stat_owned(), S_IWGRP, S_IWOTH, and S_IWUSR.

Referenced by Init_File().

◆ rb_stat_W()

static VALUE rb_stat_W ( VALUE  obj)
static

Definition at line 5310 of file file.c.

References get_stat(), getuid(), Qfalse, Qtrue, rb_group_member(), rb_stat_rowned(), S_IWGRP, S_IWOTH, and S_IWUSR.

Referenced by Init_File().

◆ rb_stat_wr()

static VALUE rb_stat_wr ( VALUE  obj)
static

Definition at line 5252 of file file.c.

References get_stat(), Qnil, S_IROTH, S_IRUGO, S_IWUGO, S_IXUGO, and UINT2NUM.

Referenced by Init_File().

◆ rb_stat_ww()

static VALUE rb_stat_ww ( VALUE  obj)
static

Definition at line 5345 of file file.c.

References get_stat(), Qnil, S_IRUGO, S_IWOTH, S_IWUGO, S_IXUGO, and UINT2NUM.

Referenced by Init_File().

◆ rb_stat_x()

static VALUE rb_stat_x ( VALUE  obj)
static

Definition at line 5372 of file file.c.

References get_stat(), geteuid(), Qfalse, Qtrue, rb_stat_grpowned(), rb_stat_owned(), S_IXGRP, S_IXOTH, S_IXUGO, and S_IXUSR.

Referenced by Init_File().

◆ rb_stat_X()

static VALUE rb_stat_X ( VALUE  obj)
static

Definition at line 5404 of file file.c.

References get_stat(), getuid(), Qfalse, Qtrue, rb_group_member(), rb_stat_rowned(), S_IXGRP, S_IXOTH, S_IXUGO, and S_IXUSR.

Referenced by Init_File().

◆ rb_stat_z()

static VALUE rb_stat_z ( VALUE  obj)
static

Definition at line 5457 of file file.c.

References get_stat(), Qfalse, and Qtrue.

Referenced by Init_File().

◆ rb_str_encode_ospath()

VALUE rb_str_encode_ospath ( VALUE  path)

◆ rb_thread_flock()

static VALUE rb_thread_flock ( void *  data)
static

Definition at line 4586 of file file.c.

References errno, and flock().

Referenced by rb_file_flock().

◆ realpath_rec()

static void realpath_rec ( long *  prefixlenp,
VALUE resolvedp,
const char *  unresolved,
VALUE  loopcheck,
int  strict,
int  last 
)
static

◆ rmext()

static size_t rmext ( const char *  p,
long  l0,
long  l1,
const char *  e,
long  l2,
rb_encoding enc 
)
static

Definition at line 3998 of file file.c.

References fncomp, last, rb_enc_ascget(), rb_enc_codepoint_len(), and rb_enc_left_char_head.

Referenced by rb_file_s_basename().

◆ ruby_enc_find_basename()

const char* ruby_enc_find_basename ( const char *  name,
long *  baselen,
long *  alllen,
rb_encoding enc 
)

Definition at line 4034 of file file.c.

References chompdirsep(), f, Inc, isdirsep, name, skipprefix, strlen(), and strrdirsep.

Referenced by rb_file_s_basename().

◆ ruby_enc_find_extname()

const char* ruby_enc_find_extname ( const char *  name,
long *  len,
rb_encoding enc 
)

Definition at line 4232 of file file.c.

References Inc, isADS, isdirsep, istrailinggarbage, last, len, name, strlen(), and strrdirsep.

Referenced by path_sub_ext(), and rb_file_s_extname().

◆ ruby_is_fd_loadable()

int ruby_is_fd_loadable ( int  fd)

Definition at line 5697 of file file.c.

References errno, fstat, S_ISDIR, and S_ISREG.

Referenced by open_load_file(), and rb_file_load_ok().

◆ skipprefixroot()

static char* skipprefixroot ( const char *  path,
const char *  end,
rb_encoding enc 
)
inlinestatic

Definition at line 3055 of file file.c.

References isdirsep, skipprefix, and skiproot().

Referenced by rb_realpath_internal(), and realpath_rec().

◆ skiproot()

static char* skiproot ( const char *  path,
const char *  end,
rb_encoding enc 
)
inlinestatic

Definition at line 3009 of file file.c.

References isdirsep.

Referenced by rb_file_dirname(), rb_file_expand_path_internal(), and skipprefixroot().

◆ stat_atime()

static VALUE stat_atime ( struct stat st)
static

◆ stat_atimespec()

static struct timespec stat_atimespec ( struct stat st)
static

Definition at line 760 of file file.c.

References timespec::tv_nsec, and timespec::tv_sec.

Referenced by stat_atime().

◆ stat_ctime()

static VALUE stat_ctime ( struct stat st)
static

◆ stat_ctimespec()

static struct timespec stat_ctimespec ( struct stat st)
static

Definition at line 808 of file file.c.

References timespec::tv_nsec, and timespec::tv_sec.

Referenced by stat_ctime().

◆ stat_memsize()

static size_t stat_memsize ( const void *  p)
static

Definition at line 390 of file file.c.

References stat.

◆ stat_mtime()

static VALUE stat_mtime ( struct stat st)
static

◆ stat_mtimespec()

static struct timespec stat_mtimespec ( struct stat st)
static

Definition at line 784 of file file.c.

References timespec::tv_nsec, and timespec::tv_sec.

Referenced by rb_f_test(), rb_stat_cmp(), and stat_mtime().

◆ stat_new_0()

static VALUE stat_new_0 ( VALUE  klass,
const struct stat st 
)
static

Definition at line 402 of file file.c.

References ALLOC, RTYPEDDATA_DATA, stat, and TypedData_Wrap_Struct.

Referenced by rb_stat_new(), and rb_stat_s_alloc().

◆ str_shrink()

static VALUE str_shrink ( VALUE  str)
static

Definition at line 3666 of file file.c.

References rb_str_resize(), and RSTRING_LEN.

Referenced by copy_path_class().

◆ syserr_fail2_in()

static void syserr_fail2_in ( const char *  func,
int  e,
VALUE  s1,
VALUE  s2 
)
static

◆ test_check()

static void test_check ( int  n,
int  argc,
VALUE argv 
)
static

Definition at line 4690 of file file.c.

References FilePathValue, rb_check_arity, RB_TYPE_P, and T_FILE.

◆ to_gid()

static rb_gid_t to_gid ( VALUE  g)
inlinestatic

Definition at line 2400 of file file.c.

References NIL_P, and NUM2GIDT.

Referenced by rb_file_chown(), and rb_file_s_chown().

◆ to_uid()

static rb_uid_t to_uid ( VALUE  u)
inlinestatic

Definition at line 2391 of file file.c.

References NIL_P, and NUM2UIDT.

Referenced by rb_file_chown(), and rb_file_s_chown().

◆ unlink_internal()

static void unlink_internal ( const char *  path,
VALUE  pathv,
void *  arg 
)
static

Definition at line 2806 of file file.c.

References rb_sys_fail_path.

Referenced by rb_file_s_unlink().

◆ utime_internal()

static void utime_internal ( const char *  path,
VALUE  pathv,
void *  arg 
)
static

Variable Documentation

◆ null_device

const char null_device[]
static
Initial value:
=
"/dev/null"

Definition at line 5906 of file file.c.

◆ rb_cFile

VALUE rb_cFile

◆ rb_cStat

VALUE rb_cStat

Definition at line 131 of file file.c.

Referenced by Init_File(), and rb_stat_new().

◆ rb_mFConst

VALUE rb_mFConst

Definition at line 5582 of file file.c.

◆ rb_mFileTest

VALUE rb_mFileTest

◆ separator

VALUE separator
static

Definition at line 4360 of file file.c.

Referenced by chunk_ii().

◆ stat_data_type

const rb_data_type_t stat_data_type
static
Initial value:
= {
"stat",
}
#define RUBY_TYPED_FREE_IMMEDIATELY
Definition: ruby.h:1145
static size_t stat_memsize(const void *p)
Definition: file.c:390
#define RUBY_TYPED_DEFAULT_FREE
Definition: ruby.h:1141
#define NULL
Definition: _sdbm.c:102

Definition at line 395 of file file.c.