Ruby
2.4.2p198(2017-09-14revision59899)
|
#include "ruby/ruby.h"
#include "ruby/encoding.h"
#include "internal.h"
#include <winbase.h>
#include <wchar.h>
#include <shlwapi.h>
#include "win32/file.h"
Go to the source code of this file.
Data Structures | |
struct | code_page_table |
Macros | |
#define | INVALID_FILE_ATTRIBUTES ((DWORD)-1) |
#define | IS_DIR_SEPARATOR_P(c) (c == L'\\' || c == L'/') |
#define | IS_DIR_UNC_P(c) (IS_DIR_SEPARATOR_P(c[0]) && IS_DIR_SEPARATOR_P(c[1])) |
#define | INVALID_CODE_PAGE 51932 |
#define | PATH_BUFFER_SIZE MAX_PATH * 2 |
#define | insecure_obj_p(obj, level) ((level) > 0 && OBJ_TAINTED(obj)) |
#define | system_code_page rb_w32_filecp |
#define | mbstr_to_wstr rb_w32_mbstr_to_wstr |
#define | wstr_to_mbstr rb_w32_wstr_to_mbstr |
#define | fix_string_encoding(str, encoding) rb_str_conv_enc((str), (encoding), rb_utf8_encoding()) |
Functions | |
static void | replace_wchar (wchar_t *s, int find, int replace) |
static size_t | remove_invalid_alternative_data (wchar_t *wfullpath, size_t size) |
void | rb_enc_foreach_name (int(*func)(st_data_t name, st_data_t idx, st_data_t arg), st_data_t arg) |
static int | code_page_i (st_data_t name, st_data_t idx, st_data_t arg) |
static UINT | code_page (rb_encoding *enc) |
static size_t | replace_to_long_name (wchar_t **wfullpath, size_t size, size_t buffer_size) |
static size_t | user_length_in_path (const wchar_t *wuser, size_t len) |
static VALUE | append_wstr (VALUE dst, const WCHAR *ws, ssize_t len, UINT cp, rb_encoding *enc) |
VALUE | rb_default_home_dir (VALUE result) |
VALUE | rb_file_expand_path_internal (VALUE fname, VALUE dname, int abs_mode, int long_name, VALUE result) |
VALUE | rb_readlink (VALUE path, rb_encoding *resultenc) |
int | rb_file_load_ok (const char *path) |
int | rb_freopen (VALUE fname, const char *mode, FILE *file) |
void | Init_w32_codepage (void) |
Variables | |
static struct code_page_table | rb_code_page |
#define fix_string_encoding | ( | str, | |
encoding | |||
) | rb_str_conv_enc((str), (encoding), rb_utf8_encoding()) |
Definition at line 135 of file file.c.
Referenced by rb_file_expand_path_internal(), and rb_readlink().
#define insecure_obj_p | ( | obj, | |
level | |||
) | ((level) > 0 && OBJ_TAINTED(obj)) |
#define INVALID_CODE_PAGE 51932 |
Definition at line 27 of file file.c.
Referenced by append_wstr(), code_page(), code_page_i(), rb_file_expand_path_internal(), and rb_readlink().
#define INVALID_FILE_ATTRIBUTES ((DWORD)-1) |
Definition at line 14 of file file.c.
Referenced by rb_file_load_ok().
Definition at line 23 of file file.c.
Referenced by rb_file_expand_path_internal(), remove_invalid_alternative_data(), replace_to_long_name(), and user_length_in_path().
#define IS_DIR_UNC_P | ( | c | ) | (IS_DIR_SEPARATOR_P(c[0]) && IS_DIR_SEPARATOR_P(c[1])) |
Definition at line 24 of file file.c.
Referenced by rb_file_expand_path_internal().
#define mbstr_to_wstr rb_w32_mbstr_to_wstr |
Definition at line 34 of file file.c.
Referenced by rb_file_expand_path_internal(), and rb_file_load_ok().
#define PATH_BUFFER_SIZE MAX_PATH * 2 |
Definition at line 28 of file file.c.
Referenced by rb_file_expand_path_internal().
#define system_code_page rb_w32_filecp |
Definition at line 33 of file file.c.
Referenced by code_page(), and rb_file_expand_path_internal().
#define wstr_to_mbstr rb_w32_wstr_to_mbstr |
Definition at line 35 of file file.c.
Referenced by append_wstr().
|
static |
Definition at line 215 of file file.c.
References ECONV_INVALID_REPLACE, ECONV_UNDEF_REPLACE, free(), INVALID_CODE_PAGE, NULL, rb_econv_append(), rb_econv_close(), rb_econv_open(), rb_enc_associate(), rb_enc_name, rb_str_modify_expand(), rb_str_set_len(), RSTRING_LEN, RSTRING_PTR, and wstr_to_mbstr.
Referenced by rb_default_home_dir(), rb_file_expand_path_internal(), and rb_readlink().
|
static |
Definition at line 112 of file file.c.
References code_page_table::count, INVALID_CODE_PAGE, rb_ascii8bit_encindex(), rb_code_page, rb_enc_to_index(), rb_usascii_encindex(), rb_utf8_encindex(), system_code_page, and code_page_table::table.
Referenced by code_page_i(), rb_file_expand_path_internal(), and rb_readlink().
Definition at line 82 of file file.c.
References code_page(), code_page_table::count, INVALID_CODE_PAGE, realloc, ST_CONTINUE, and code_page_table::table.
Referenced by Init_w32_codepage().
void Init_w32_codepage | ( | void | ) |
Definition at line 703 of file file.c.
References code_page_i(), code_page_table::count, rb_code_page, rb_enc_foreach_name(), and st_data_t.
Referenced by rb_locale_encindex().
Definition at line 240 of file file.c.
References append_wstr(), copy_home_path(), endpwent, getenv, getlogin(), rb_eArgError, rb_filesystem_encoding(), rb_raise(), rb_w32_filecp(), rb_w32_home_dir(), result, and xfree().
void rb_enc_foreach_name | ( | int(*)(st_data_t name, st_data_t idx, st_data_t arg) | func, |
st_data_t | arg | ||
) |
Definition at line 1964 of file encoding.c.
References enc_table, func, and st_foreach.
Referenced by Init_w32_codepage(), and remove_invalid_alternative_data().
VALUE rb_file_expand_path_internal | ( | VALUE | fname, |
VALUE | dname, | ||
int | abs_mode, | ||
int | long_name, | ||
VALUE | result | ||
) |
Definition at line 253 of file file.c.
References ALLOC_N, ALLOCA_N, ALLOCV_END, ALLOCV_N, append_fspath(), append_wstr(), buf, BUFCHECK, BUFCOPY, BUFINIT, chompdirsep(), code_page(), ENC_CODERANGE_7BIT, ENC_CODERANGE_CLEAR, ENCINDEX_UTF_8, ENCODING_GET, fix_string_encoding, free(), Inc, INVALID_CODE_PAGE, IS_DIR_SEPARATOR_P, IS_DIR_UNC_P, isADS, isdirsep, istrailinggarbage, L, len, lstat, MAXPATHLEN, mbstr_to_wstr, memcpy, my_getcwd, nextdirsep, NIL_P, NULL, OBJ_TAINT, OBJ_TAINTED, PATH_BUFFER_SIZE, path_drive(), PRIsVALUE, Qnil, rb_default_home_dir(), rb_eArgError, rb_enc_associate(), rb_enc_check(), rb_enc_copy(), rb_enc_get(), rb_enc_raise(), rb_enc_str_asciionly_p(), rb_enc_str_coderange(), rb_eRangeError, rb_exc_new_str(), rb_exc_raise(), rb_file_expand_path_internal(), rb_filesystem_encoding(), rb_home_dir_of(), rb_is_absolute_path(), rb_raise(), rb_str_cat_conv_enc_opts(), rb_str_encode_ospath(), rb_str_modify_expand(), rb_str_new_cstr(), rb_str_resize(), rb_str_set_len(), rb_utf8_encoding(), rb_w32_home_dir(), remove_invalid_alternative_data(), replace_to_long_name(), replace_wchar(), result, RSTRING_LEN, RSTRING_PTR, S_ISLNK, size, skipprefix, skiproot(), STRCASECMP, StringValuePtr, strlcat(), strlen(), strncasecmp, strrdirsep, system_code_page, TOLOWER, user_length_in_path(), WITH_ROOTDIFF, and xfree().
int rb_file_load_ok | ( | const char * | path | ) |
Definition at line 643 of file file.c.
References free(), INVALID_FILE_ATTRIBUTES, len, mbstr_to_wstr, NULL, O_NONBLOCK, rb_cloexec_open(), rb_update_max_fd(), and ruby_is_fd_loadable().
Definition at line 674 of file file.c.
References ALLOCV_END, ALLOCV_N, errno, L, len, name, NULL, numberof, RB_GC_GUARD, rb_long2int, and RSTRING_GETMEM.
VALUE rb_readlink | ( | VALUE | path, |
rb_encoding * | resultenc | ||
) |
Definition at line 599 of file file.c.
References ALLOCV, ALLOCV_END, ALLOCV_N, append_wstr(), code_page(), FilePathValue, fix_string_encoding, INVALID_CODE_PAGE, L, len, NULL, rb_enc_get(), rb_enc_str_new(), rb_syserr_fail_path, rb_w32_map_errno(), rb_w32_read_reparse_point(), rb_w32_reparse_buffer_size, RSTRING_LEN, RSTRING_PTR, and size.
Referenced by realpath_rec(), and ruby_init_loadpath().
|
inlinestatic |
Definition at line 49 of file file.c.
References func, IS_DIR_SEPARATOR_P, L, name, rb_enc_foreach_name(), size, and st_data_t.
Referenced by rb_file_expand_path_internal().
|
inlinestatic |
Definition at line 142 of file file.c.
References ALLOC_N, buf, IS_DIR_SEPARATOR_P, L, size, and xfree().
Referenced by rb_file_expand_path_internal().
|
inlinestatic |
Definition at line 38 of file file.c.
Referenced by rb_file_expand_path_internal().
|
inlinestatic |
Definition at line 204 of file file.c.
References IS_DIR_SEPARATOR_P.
Referenced by rb_file_expand_path_internal().
|
static |
Referenced by code_page(), and Init_w32_codepage().