1 #ifndef Py_CPYTHON_FILEUTILS_H 2 # error "this header file must not be included directly" 3 #endif 4 5 typedef enum { 6 _Py_ERROR_UNKNOWN=0, 7 _Py_ERROR_STRICT, 8 _Py_ERROR_SURROGATEESCAPE, 9 _Py_ERROR_REPLACE, 10 _Py_ERROR_IGNORE, 11 _Py_ERROR_BACKSLASHREPLACE, 12 _Py_ERROR_SURROGATEPASS, 13 _Py_ERROR_XMLCHARREFREPLACE, 14 _Py_ERROR_OTHER 15 } _Py_error_handler; 16 17 PyAPI_FUNC(_Py_error_handler) _Py_GetErrorHandler(const char *errors); 18 19 PyAPI_FUNC(int) _Py_DecodeLocaleEx( 20 const char *arg, 21 wchar_t **wstr, 22 size_t *wlen, 23 const char **reason, 24 int current_locale, 25 _Py_error_handler errors); 26 27 PyAPI_FUNC(int) _Py_EncodeLocaleEx( 28 const wchar_t *text, 29 char **str, 30 size_t *error_pos, 31 const char **reason, 32 int current_locale, 33 _Py_error_handler errors); 34 35 36 PyAPI_FUNC(PyObject *) _Py_device_encoding(int); 37 38 #if defined(MS_WINDOWS) || defined(__APPLE__) 39 /* On Windows, the count parameter of read() is an int (bpo-9015, bpo-9611). 40 On macOS 10.13, read() and write() with more than INT_MAX bytes 41 fail with EINVAL (bpo-24658). */ 42 # define _PY_READ_MAX INT_MAX 43 # define _PY_WRITE_MAX INT_MAX 44 #else 45 /* write() should truncate the input to PY_SSIZE_T_MAX bytes, 46 but it's safer to do it ourself to have a portable behaviour */ 47 # define _PY_READ_MAX PY_SSIZE_T_MAX 48 # define _PY_WRITE_MAX PY_SSIZE_T_MAX 49 #endif 50 51 #ifdef MS_WINDOWS 52 struct _Py_stat_struct { 53 unsigned long st_dev; 54 uint64_t st_ino; 55 unsigned short st_mode; 56 int st_nlink; 57 int st_uid; 58 int st_gid; 59 unsigned long st_rdev; 60 __int64 st_size; 61 time_t st_atime; 62 int st_atime_nsec; 63 time_t st_mtime; 64 int st_mtime_nsec; 65 time_t st_ctime; 66 int st_ctime_nsec; 67 unsigned long st_file_attributes; 68 unsigned long st_reparse_tag; 69 }; 70 #else 71 # define _Py_stat_struct stat 72 #endif 73 74 PyAPI_FUNC(int) _Py_fstat( 75 int fd, 76 struct _Py_stat_struct *status); 77 78 PyAPI_FUNC(int) _Py_fstat_noraise( 79 int fd, 80 struct _Py_stat_struct *status); 81 82 PyAPI_FUNC(int) _Py_stat( 83 PyObject *path, 84 struct stat *status); 85 86 PyAPI_FUNC(int) _Py_open( 87 const char *pathname, 88 int flags); 89 90 PyAPI_FUNC(int) _Py_open_noraise( 91 const char *pathname, 92 int flags); 93 94 PyAPI_FUNC(FILE *) _Py_wfopen( 95 const wchar_t *path, 96 const wchar_t *mode); 97 98 PyAPI_FUNC(FILE*) _Py_fopen( 99 const char *pathname, 100 const char *mode); 101 102 PyAPI_FUNC(FILE*) _Py_fopen_obj( 103 PyObject *path, 104 const char *mode); 105 106 PyAPI_FUNC(Py_ssize_t) _Py_read( 107 int fd, 108 void *buf, 109 size_t count); 110 111 PyAPI_FUNC(Py_ssize_t) _Py_write( 112 int fd, 113 const void *buf, 114 size_t count); 115 116 PyAPI_FUNC(Py_ssize_t) _Py_write_noraise( 117 int fd, 118 const void *buf, 119 size_t count); 120 121 #ifdef HAVE_READLINK 122 PyAPI_FUNC(int) _Py_wreadlink( 123 const wchar_t *path, 124 wchar_t *buf, 125 /* Number of characters of 'buf' buffer 126 including the trailing NUL character */ 127 size_t buflen); 128 #endif 129 130 #ifdef HAVE_REALPATH 131 PyAPI_FUNC(wchar_t*) _Py_wrealpath( 132 const wchar_t *path, 133 wchar_t *resolved_path, 134 /* Number of characters of 'resolved_path' buffer 135 including the trailing NUL character */ 136 size_t resolved_path_len); 137 #endif 138 139 #ifndef MS_WINDOWS 140 PyAPI_FUNC(int) _Py_isabs(const wchar_t *path); 141 #endif 142 143 PyAPI_FUNC(int) _Py_abspath(const wchar_t *path, wchar_t **abspath_p); 144 145 PyAPI_FUNC(wchar_t*) _Py_wgetcwd( 146 wchar_t *buf, 147 /* Number of characters of 'buf' buffer 148 including the trailing NUL character */ 149 size_t buflen); 150 151 PyAPI_FUNC(int) _Py_get_inheritable(int fd); 152 153 PyAPI_FUNC(int) _Py_set_inheritable(int fd, int inheritable, 154 int *atomic_flag_works); 155 156 PyAPI_FUNC(int) _Py_set_inheritable_async_safe(int fd, int inheritable, 157 int *atomic_flag_works); 158 159 PyAPI_FUNC(int) _Py_dup(int fd); 160 161 #ifndef MS_WINDOWS 162 PyAPI_FUNC(int) _Py_get_blocking(int fd); 163 164 PyAPI_FUNC(int) _Py_set_blocking(int fd, int blocking); 165 #endif /* !MS_WINDOWS */ 166