|
| 1 | +#ifndef Py_FILEUTILS_H |
| 2 | +#define Py_FILEUTILS_H |
| 3 | + |
| 4 | +#ifdef __cplusplus |
| 5 | +extern "C" { |
| 6 | +#endif |
| 7 | + |
| 8 | +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000 |
| 9 | +PyAPI_FUNC(wchar_t *) Py_DecodeLocale( |
| 10 | + const char *arg, |
| 11 | + size_t *size); |
| 12 | + |
| 13 | +PyAPI_FUNC(char*) Py_EncodeLocale( |
| 14 | + const wchar_t *text, |
| 15 | + size_t *error_pos); |
| 16 | + |
| 17 | +PyAPI_FUNC(char*) _Py_EncodeLocaleRaw( |
| 18 | + const wchar_t *text, |
| 19 | + size_t *error_pos); |
| 20 | +#endif |
| 21 | + |
| 22 | +#ifdef Py_BUILD_CORE |
| 23 | +PyAPI_FUNC(int) _Py_DecodeUTF8Ex( |
| 24 | + const char *arg, |
| 25 | + Py_ssize_t arglen, |
| 26 | + wchar_t **wstr, |
| 27 | + size_t *wlen, |
| 28 | + const char **reason, |
| 29 | + int surrogateescape); |
| 30 | + |
| 31 | +PyAPI_FUNC(int) _Py_EncodeUTF8Ex( |
| 32 | + const wchar_t *text, |
| 33 | + char **str, |
| 34 | + size_t *error_pos, |
| 35 | + const char **reason, |
| 36 | + int raw_malloc, |
| 37 | + int surrogateescape); |
| 38 | + |
| 39 | +PyAPI_FUNC(wchar_t*) _Py_DecodeUTF8_surrogateescape( |
| 40 | + const char *arg, |
| 41 | + Py_ssize_t arglen); |
| 42 | + |
| 43 | +PyAPI_FUNC(int) _Py_DecodeLocaleEx( |
| 44 | + const char *arg, |
| 45 | + wchar_t **wstr, |
| 46 | + size_t *wlen, |
| 47 | + const char **reason, |
| 48 | + int current_locale, |
| 49 | + int surrogateescape); |
| 50 | + |
| 51 | +PyAPI_FUNC(int) _Py_EncodeLocaleEx( |
| 52 | + const wchar_t *text, |
| 53 | + char **str, |
| 54 | + size_t *error_pos, |
| 55 | + const char **reason, |
| 56 | + int current_locale, |
| 57 | + int surrogateescape); |
| 58 | +#endif |
| 59 | + |
| 60 | +#ifndef Py_LIMITED_API |
| 61 | +PyAPI_FUNC(PyObject *) _Py_device_encoding(int); |
| 62 | + |
| 63 | +#if defined(MS_WINDOWS) || defined(__APPLE__) |
| 64 | + /* On Windows, the count parameter of read() is an int (bpo-9015, bpo-9611). |
| 65 | + On macOS 10.13, read() and write() with more than INT_MAX bytes |
| 66 | + fail with EINVAL (bpo-24658). */ |
| 67 | +# define _PY_READ_MAX INT_MAX |
| 68 | +# define _PY_WRITE_MAX INT_MAX |
| 69 | +#else |
| 70 | + /* write() should truncate the input to PY_SSIZE_T_MAX bytes, |
| 71 | + but it's safer to do it ourself to have a portable behaviour */ |
| 72 | +# define _PY_READ_MAX PY_SSIZE_T_MAX |
| 73 | +# define _PY_WRITE_MAX PY_SSIZE_T_MAX |
| 74 | +#endif |
| 75 | + |
| 76 | +#ifdef MS_WINDOWS |
| 77 | +struct _Py_stat_struct { |
| 78 | + unsigned long st_dev; |
| 79 | + uint64_t st_ino; |
| 80 | + unsigned short st_mode; |
| 81 | + int st_nlink; |
| 82 | + int st_uid; |
| 83 | + int st_gid; |
| 84 | + unsigned long st_rdev; |
| 85 | + __int64 st_size; |
| 86 | + time_t st_atime; |
| 87 | + int st_atime_nsec; |
| 88 | + time_t st_mtime; |
| 89 | + int st_mtime_nsec; |
| 90 | + time_t st_ctime; |
| 91 | + int st_ctime_nsec; |
| 92 | + unsigned long st_file_attributes; |
| 93 | +}; |
| 94 | +#else |
| 95 | +# define _Py_stat_struct stat |
| 96 | +#endif |
| 97 | + |
| 98 | +PyAPI_FUNC(int) _Py_fstat( |
| 99 | + int fd, |
| 100 | + struct _Py_stat_struct *status); |
| 101 | + |
| 102 | +PyAPI_FUNC(int) _Py_fstat_noraise( |
| 103 | + int fd, |
| 104 | + struct _Py_stat_struct *status); |
| 105 | + |
| 106 | +PyAPI_FUNC(int) _Py_stat( |
| 107 | + PyObject *path, |
| 108 | + struct stat *status); |
| 109 | + |
| 110 | +PyAPI_FUNC(int) _Py_open( |
| 111 | + const char *pathname, |
| 112 | + int flags); |
| 113 | + |
| 114 | +PyAPI_FUNC(int) _Py_open_noraise( |
| 115 | + const char *pathname, |
| 116 | + int flags); |
| 117 | + |
| 118 | +PyAPI_FUNC(FILE *) _Py_wfopen( |
| 119 | + const wchar_t *path, |
| 120 | + const wchar_t *mode); |
| 121 | + |
| 122 | +PyAPI_FUNC(FILE*) _Py_fopen( |
| 123 | + const char *pathname, |
| 124 | + const char *mode); |
| 125 | + |
| 126 | +PyAPI_FUNC(FILE*) _Py_fopen_obj( |
| 127 | + PyObject *path, |
| 128 | + const char *mode); |
| 129 | + |
| 130 | +PyAPI_FUNC(Py_ssize_t) _Py_read( |
| 131 | + int fd, |
| 132 | + void *buf, |
| 133 | + size_t count); |
| 134 | + |
| 135 | +PyAPI_FUNC(Py_ssize_t) _Py_write( |
| 136 | + int fd, |
| 137 | + const void *buf, |
| 138 | + size_t count); |
| 139 | + |
| 140 | +PyAPI_FUNC(Py_ssize_t) _Py_write_noraise( |
| 141 | + int fd, |
| 142 | + const void *buf, |
| 143 | + size_t count); |
| 144 | + |
| 145 | +#ifdef HAVE_READLINK |
| 146 | +PyAPI_FUNC(int) _Py_wreadlink( |
| 147 | + const wchar_t *path, |
| 148 | + wchar_t *buf, |
| 149 | + size_t bufsiz); |
| 150 | +#endif |
| 151 | + |
| 152 | +#ifdef HAVE_REALPATH |
| 153 | +PyAPI_FUNC(wchar_t*) _Py_wrealpath( |
| 154 | + const wchar_t *path, |
| 155 | + wchar_t *resolved_path, |
| 156 | + size_t resolved_path_size); |
| 157 | +#endif |
| 158 | + |
| 159 | +PyAPI_FUNC(wchar_t*) _Py_wgetcwd( |
| 160 | + wchar_t *buf, |
| 161 | + size_t size); |
| 162 | + |
| 163 | +PyAPI_FUNC(int) _Py_get_inheritable(int fd); |
| 164 | + |
| 165 | +PyAPI_FUNC(int) _Py_set_inheritable(int fd, int inheritable, |
| 166 | + int *atomic_flag_works); |
| 167 | + |
| 168 | +PyAPI_FUNC(int) _Py_set_inheritable_async_safe(int fd, int inheritable, |
| 169 | + int *atomic_flag_works); |
| 170 | + |
| 171 | +PyAPI_FUNC(int) _Py_dup(int fd); |
| 172 | + |
| 173 | +#ifndef MS_WINDOWS |
| 174 | +PyAPI_FUNC(int) _Py_get_blocking(int fd); |
| 175 | + |
| 176 | +PyAPI_FUNC(int) _Py_set_blocking(int fd, int blocking); |
| 177 | +#endif /* !MS_WINDOWS */ |
| 178 | + |
| 179 | +PyAPI_FUNC(int) _Py_GetLocaleconvNumeric( |
| 180 | + PyObject **decimal_point, |
| 181 | + PyObject **thousands_sep, |
| 182 | + const char **grouping); |
| 183 | + |
| 184 | +#endif /* Py_LIMITED_API */ |
| 185 | + |
| 186 | +#ifdef Py_BUILD_CORE |
| 187 | +PyAPI_FUNC(int) _Py_GetForceASCII(void); |
| 188 | + |
| 189 | +/* Reset "force ASCII" mode (if it was initialized). |
| 190 | +
|
| 191 | + This function should be called when Python changes the LC_CTYPE locale, |
| 192 | + so the "force ASCII" mode can be detected again on the new locale |
| 193 | + encoding. */ |
| 194 | +PyAPI_FUNC(void) _Py_ResetForceASCII(void); |
| 195 | +#endif |
| 196 | + |
| 197 | +#ifdef __cplusplus |
| 198 | +} |
| 199 | +#endif |
| 200 | + |
| 201 | +#endif /* !Py_FILEUTILS_H */ |
0 commit comments