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

source code of include/python3.10/cpython/fileutils.h