blob: f0a8e2c61a4fe0a3557f3abab13f4660cc556c88 [file] [log] [blame]
Victor Stinner4e314432010-10-07 21:45:39 +00001#ifndef Py_FILEUTILS_H
2#define Py_FILEUTILS_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
Victor Stinner3d4226a2018-08-29 22:21:32 +02008
9#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03080000
10typedef enum {
11 _Py_ERROR_UNKNOWN=0,
12 _Py_ERROR_STRICT,
13 _Py_ERROR_SURROGATEESCAPE,
14 _Py_ERROR_REPLACE,
15 _Py_ERROR_IGNORE,
16 _Py_ERROR_BACKSLASHREPLACE,
17 _Py_ERROR_SURROGATEPASS,
18 _Py_ERROR_XMLCHARREFREPLACE,
19 _Py_ERROR_OTHER
20} _Py_error_handler;
21
22PyAPI_FUNC(_Py_error_handler) _Py_GetErrorHandler(const char *errors);
23#endif
24
25
Serhiy Storchaka34d0ac82016-12-27 14:57:39 +020026#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
Victor Stinnerf6a271a2014-08-01 12:28:48 +020027PyAPI_FUNC(wchar_t *) Py_DecodeLocale(
Victor Stinner168e1172010-10-16 23:16:16 +000028 const char *arg,
29 size_t *size);
Victor Stinner4e314432010-10-07 21:45:39 +000030
Victor Stinnerf6a271a2014-08-01 12:28:48 +020031PyAPI_FUNC(char*) Py_EncodeLocale(
Victor Stinner2f02a512010-11-08 22:43:46 +000032 const wchar_t *text,
33 size_t *error_pos);
Victor Stinner9dd76202017-12-21 16:20:32 +010034
35PyAPI_FUNC(char*) _Py_EncodeLocaleRaw(
36 const wchar_t *text,
37 size_t *error_pos);
Serhiy Storchaka34d0ac82016-12-27 14:57:39 +020038#endif
Victor Stinner4e314432010-10-07 21:45:39 +000039
Victor Stinner9bee3292017-12-21 16:49:13 +010040#ifdef Py_BUILD_CORE
Victor Stinner7ed7aea2018-01-15 10:45:49 +010041PyAPI_FUNC(int) _Py_DecodeUTF8Ex(
Victor Stinner2cba6b82018-01-10 22:46:15 +010042 const char *arg,
Victor Stinner7ed7aea2018-01-15 10:45:49 +010043 Py_ssize_t arglen,
44 wchar_t **wstr,
45 size_t *wlen,
46 const char **reason,
Victor Stinner3d4226a2018-08-29 22:21:32 +020047 _Py_error_handler errors);
Victor Stinner2cba6b82018-01-10 22:46:15 +010048
Victor Stinner7ed7aea2018-01-15 10:45:49 +010049PyAPI_FUNC(int) _Py_EncodeUTF8Ex(
Victor Stinner2cba6b82018-01-10 22:46:15 +010050 const wchar_t *text,
Victor Stinner7ed7aea2018-01-15 10:45:49 +010051 char **str,
52 size_t *error_pos,
53 const char **reason,
54 int raw_malloc,
Victor Stinner3d4226a2018-08-29 22:21:32 +020055 _Py_error_handler errors);
Victor Stinner7ed7aea2018-01-15 10:45:49 +010056
57PyAPI_FUNC(wchar_t*) _Py_DecodeUTF8_surrogateescape(
58 const char *arg,
59 Py_ssize_t arglen);
Victor Stinner3d4226a2018-08-29 22:21:32 +020060#endif
Victor Stinner7ed7aea2018-01-15 10:45:49 +010061
Victor Stinner3d4226a2018-08-29 22:21:32 +020062
63#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03080000
Victor Stinner7ed7aea2018-01-15 10:45:49 +010064PyAPI_FUNC(int) _Py_DecodeLocaleEx(
65 const char *arg,
66 wchar_t **wstr,
67 size_t *wlen,
68 const char **reason,
69 int current_locale,
Victor Stinner3d4226a2018-08-29 22:21:32 +020070 _Py_error_handler errors);
Victor Stinner7ed7aea2018-01-15 10:45:49 +010071
72PyAPI_FUNC(int) _Py_EncodeLocaleEx(
73 const wchar_t *text,
74 char **str,
75 size_t *error_pos,
76 const char **reason,
77 int current_locale,
Victor Stinner3d4226a2018-08-29 22:21:32 +020078 _Py_error_handler errors);
Victor Stinner9bee3292017-12-21 16:49:13 +010079#endif
80
Serhiy Storchaka12ebbc72015-02-22 19:39:36 +020081#ifndef Py_LIMITED_API
Serhiy Storchaka9fab79b2016-09-11 11:03:14 +030082PyAPI_FUNC(PyObject *) _Py_device_encoding(int);
83
Steve Dowerf2f373f2015-02-21 08:44:05 -080084#ifdef MS_WINDOWS
85struct _Py_stat_struct {
86 unsigned long st_dev;
Victor Stinner0f6d7332017-03-09 17:34:28 +010087 uint64_t st_ino;
Steve Dowerf2f373f2015-02-21 08:44:05 -080088 unsigned short st_mode;
89 int st_nlink;
90 int st_uid;
91 int st_gid;
92 unsigned long st_rdev;
93 __int64 st_size;
94 time_t st_atime;
95 int st_atime_nsec;
96 time_t st_mtime;
97 int st_mtime_nsec;
98 time_t st_ctime;
99 int st_ctime_nsec;
100 unsigned long st_file_attributes;
101};
102#else
103# define _Py_stat_struct stat
104#endif
105
106PyAPI_FUNC(int) _Py_fstat(
107 int fd,
Victor Stinnere134a7f2015-03-30 10:09:31 +0200108 struct _Py_stat_struct *status);
109
110PyAPI_FUNC(int) _Py_fstat_noraise(
111 int fd,
112 struct _Py_stat_struct *status);
Steve Dowerf2f373f2015-02-21 08:44:05 -0800113
Victor Stinner4e314432010-10-07 21:45:39 +0000114PyAPI_FUNC(int) _Py_stat(
Victor Stinnera4a75952010-10-07 22:23:10 +0000115 PyObject *path,
Victor Stinnere134a7f2015-03-30 10:09:31 +0200116 struct stat *status);
Victor Stinner4e314432010-10-07 21:45:39 +0000117
Victor Stinnerdaf45552013-08-28 00:53:59 +0200118PyAPI_FUNC(int) _Py_open(
119 const char *pathname,
120 int flags);
Victor Stinnera555cfc2015-03-18 00:22:14 +0100121
122PyAPI_FUNC(int) _Py_open_noraise(
123 const char *pathname,
124 int flags);
Victor Stinnerdaf45552013-08-28 00:53:59 +0200125
Victor Stinner4e314432010-10-07 21:45:39 +0000126PyAPI_FUNC(FILE *) _Py_wfopen(
127 const wchar_t *path,
128 const wchar_t *mode);
129
130PyAPI_FUNC(FILE*) _Py_fopen(
Victor Stinnerdaf45552013-08-28 00:53:59 +0200131 const char *pathname,
132 const char *mode);
133
134PyAPI_FUNC(FILE*) _Py_fopen_obj(
Victor Stinnera4a75952010-10-07 22:23:10 +0000135 PyObject *path,
Victor Stinner4e314432010-10-07 21:45:39 +0000136 const char *mode);
137
Victor Stinner66aab0c2015-03-19 22:53:20 +0100138PyAPI_FUNC(Py_ssize_t) _Py_read(
139 int fd,
140 void *buf,
141 size_t count);
142
143PyAPI_FUNC(Py_ssize_t) _Py_write(
144 int fd,
145 const void *buf,
146 size_t count);
147
Victor Stinner82c3e452015-04-01 18:34:45 +0200148PyAPI_FUNC(Py_ssize_t) _Py_write_noraise(
149 int fd,
150 const void *buf,
151 size_t count);
152
Victor Stinner4e314432010-10-07 21:45:39 +0000153#ifdef HAVE_READLINK
154PyAPI_FUNC(int) _Py_wreadlink(
155 const wchar_t *path,
156 wchar_t *buf,
157 size_t bufsiz);
158#endif
159
160#ifdef HAVE_REALPATH
161PyAPI_FUNC(wchar_t*) _Py_wrealpath(
162 const wchar_t *path,
Victor Stinner015f4d82010-10-07 22:29:53 +0000163 wchar_t *resolved_path,
164 size_t resolved_path_size);
Victor Stinner4e314432010-10-07 21:45:39 +0000165#endif
166
167PyAPI_FUNC(wchar_t*) _Py_wgetcwd(
168 wchar_t *buf,
169 size_t size);
170
Victor Stinnerdaf45552013-08-28 00:53:59 +0200171PyAPI_FUNC(int) _Py_get_inheritable(int fd);
172
173PyAPI_FUNC(int) _Py_set_inheritable(int fd, int inheritable,
174 int *atomic_flag_works);
175
Alexey Izbyshevc1e46e92018-02-06 09:09:34 +0300176PyAPI_FUNC(int) _Py_set_inheritable_async_safe(int fd, int inheritable,
177 int *atomic_flag_works);
178
Victor Stinnerdaf45552013-08-28 00:53:59 +0200179PyAPI_FUNC(int) _Py_dup(int fd);
Victor Stinner1db9e7b2014-07-29 22:32:47 +0200180
181#ifndef MS_WINDOWS
182PyAPI_FUNC(int) _Py_get_blocking(int fd);
183
184PyAPI_FUNC(int) _Py_set_blocking(int fd, int blocking);
185#endif /* !MS_WINDOWS */
186
Victor Stinnercb064fc2018-01-15 15:58:02 +0100187PyAPI_FUNC(int) _Py_GetLocaleconvNumeric(
188 PyObject **decimal_point,
189 PyObject **thousands_sep,
190 const char **grouping);
191
Victor Stinner1db9e7b2014-07-29 22:32:47 +0200192#endif /* Py_LIMITED_API */
Victor Stinnerdaf45552013-08-28 00:53:59 +0200193
Victor Stinnerd500e532018-08-28 17:27:36 +0200194
195#ifdef Py_BUILD_CORE
196PyAPI_FUNC(int) _Py_GetForceASCII(void);
197#endif
198
Victor Stinner4e314432010-10-07 21:45:39 +0000199#ifdef __cplusplus
200}
201#endif
202
203#endif /* !Py_FILEUTILS_H */