blob: e4bf6d4db95d889149a9566c014640a317b832ee [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
Serhiy Storchaka34d0ac82016-12-27 14:57:39 +02008#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
Victor Stinnerf6a271a2014-08-01 12:28:48 +02009PyAPI_FUNC(wchar_t *) Py_DecodeLocale(
Victor Stinner168e1172010-10-16 23:16:16 +000010 const char *arg,
11 size_t *size);
Victor Stinner4e314432010-10-07 21:45:39 +000012
Victor Stinnerf6a271a2014-08-01 12:28:48 +020013PyAPI_FUNC(char*) Py_EncodeLocale(
Victor Stinner2f02a512010-11-08 22:43:46 +000014 const wchar_t *text,
15 size_t *error_pos);
Victor Stinner9dd76202017-12-21 16:20:32 +010016
17PyAPI_FUNC(char*) _Py_EncodeLocaleRaw(
18 const wchar_t *text,
19 size_t *error_pos);
Serhiy Storchaka34d0ac82016-12-27 14:57:39 +020020#endif
Victor Stinner4e314432010-10-07 21:45:39 +000021
Victor Stinner9bee3292017-12-21 16:49:13 +010022#ifdef Py_BUILD_CORE
Victor Stinner7ed7aea2018-01-15 10:45:49 +010023PyAPI_FUNC(int) _Py_DecodeUTF8Ex(
Victor Stinner2cba6b82018-01-10 22:46:15 +010024 const char *arg,
Victor Stinner7ed7aea2018-01-15 10:45:49 +010025 Py_ssize_t arglen,
26 wchar_t **wstr,
27 size_t *wlen,
28 const char **reason,
29 int surrogateescape);
Victor Stinner2cba6b82018-01-10 22:46:15 +010030
Victor Stinner7ed7aea2018-01-15 10:45:49 +010031PyAPI_FUNC(int) _Py_EncodeUTF8Ex(
Victor Stinner2cba6b82018-01-10 22:46:15 +010032 const wchar_t *text,
Victor Stinner7ed7aea2018-01-15 10:45:49 +010033 char **str,
34 size_t *error_pos,
35 const char **reason,
36 int raw_malloc,
37 int surrogateescape);
38
39PyAPI_FUNC(wchar_t*) _Py_DecodeUTF8_surrogateescape(
40 const char *arg,
41 Py_ssize_t arglen);
42
43PyAPI_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
51PyAPI_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);
Victor Stinner9bee3292017-12-21 16:49:13 +010058#endif
59
Serhiy Storchaka12ebbc72015-02-22 19:39:36 +020060#ifndef Py_LIMITED_API
Serhiy Storchaka9fab79b2016-09-11 11:03:14 +030061PyAPI_FUNC(PyObject *) _Py_device_encoding(int);
62
Steve Dowerf2f373f2015-02-21 08:44:05 -080063#ifdef MS_WINDOWS
64struct _Py_stat_struct {
65 unsigned long st_dev;
Victor Stinner0f6d7332017-03-09 17:34:28 +010066 uint64_t st_ino;
Steve Dowerf2f373f2015-02-21 08:44:05 -080067 unsigned short st_mode;
68 int st_nlink;
69 int st_uid;
70 int st_gid;
71 unsigned long st_rdev;
72 __int64 st_size;
73 time_t st_atime;
74 int st_atime_nsec;
75 time_t st_mtime;
76 int st_mtime_nsec;
77 time_t st_ctime;
78 int st_ctime_nsec;
79 unsigned long st_file_attributes;
80};
81#else
82# define _Py_stat_struct stat
83#endif
84
85PyAPI_FUNC(int) _Py_fstat(
86 int fd,
Victor Stinnere134a7f2015-03-30 10:09:31 +020087 struct _Py_stat_struct *status);
88
89PyAPI_FUNC(int) _Py_fstat_noraise(
90 int fd,
91 struct _Py_stat_struct *status);
Steve Dowerf2f373f2015-02-21 08:44:05 -080092
Victor Stinner4e314432010-10-07 21:45:39 +000093PyAPI_FUNC(int) _Py_stat(
Victor Stinnera4a75952010-10-07 22:23:10 +000094 PyObject *path,
Victor Stinnere134a7f2015-03-30 10:09:31 +020095 struct stat *status);
Victor Stinner4e314432010-10-07 21:45:39 +000096
Victor Stinnerdaf45552013-08-28 00:53:59 +020097PyAPI_FUNC(int) _Py_open(
98 const char *pathname,
99 int flags);
Victor Stinnera555cfc2015-03-18 00:22:14 +0100100
101PyAPI_FUNC(int) _Py_open_noraise(
102 const char *pathname,
103 int flags);
Victor Stinnerdaf45552013-08-28 00:53:59 +0200104
Victor Stinner4e314432010-10-07 21:45:39 +0000105PyAPI_FUNC(FILE *) _Py_wfopen(
106 const wchar_t *path,
107 const wchar_t *mode);
108
109PyAPI_FUNC(FILE*) _Py_fopen(
Victor Stinnerdaf45552013-08-28 00:53:59 +0200110 const char *pathname,
111 const char *mode);
112
113PyAPI_FUNC(FILE*) _Py_fopen_obj(
Victor Stinnera4a75952010-10-07 22:23:10 +0000114 PyObject *path,
Victor Stinner4e314432010-10-07 21:45:39 +0000115 const char *mode);
116
Victor Stinner66aab0c2015-03-19 22:53:20 +0100117PyAPI_FUNC(Py_ssize_t) _Py_read(
118 int fd,
119 void *buf,
120 size_t count);
121
122PyAPI_FUNC(Py_ssize_t) _Py_write(
123 int fd,
124 const void *buf,
125 size_t count);
126
Victor Stinner82c3e452015-04-01 18:34:45 +0200127PyAPI_FUNC(Py_ssize_t) _Py_write_noraise(
128 int fd,
129 const void *buf,
130 size_t count);
131
Victor Stinner4e314432010-10-07 21:45:39 +0000132#ifdef HAVE_READLINK
133PyAPI_FUNC(int) _Py_wreadlink(
134 const wchar_t *path,
135 wchar_t *buf,
136 size_t bufsiz);
137#endif
138
139#ifdef HAVE_REALPATH
140PyAPI_FUNC(wchar_t*) _Py_wrealpath(
141 const wchar_t *path,
Victor Stinner015f4d82010-10-07 22:29:53 +0000142 wchar_t *resolved_path,
143 size_t resolved_path_size);
Victor Stinner4e314432010-10-07 21:45:39 +0000144#endif
145
146PyAPI_FUNC(wchar_t*) _Py_wgetcwd(
147 wchar_t *buf,
148 size_t size);
149
Victor Stinnerdaf45552013-08-28 00:53:59 +0200150PyAPI_FUNC(int) _Py_get_inheritable(int fd);
151
152PyAPI_FUNC(int) _Py_set_inheritable(int fd, int inheritable,
153 int *atomic_flag_works);
154
Alexey Izbyshevc1e46e92018-02-06 09:09:34 +0300155PyAPI_FUNC(int) _Py_set_inheritable_async_safe(int fd, int inheritable,
156 int *atomic_flag_works);
157
Victor Stinnerdaf45552013-08-28 00:53:59 +0200158PyAPI_FUNC(int) _Py_dup(int fd);
Victor Stinner1db9e7b2014-07-29 22:32:47 +0200159
160#ifndef MS_WINDOWS
161PyAPI_FUNC(int) _Py_get_blocking(int fd);
162
163PyAPI_FUNC(int) _Py_set_blocking(int fd, int blocking);
164#endif /* !MS_WINDOWS */
165
Victor Stinnercb064fc2018-01-15 15:58:02 +0100166PyAPI_FUNC(int) _Py_GetLocaleconvNumeric(
167 PyObject **decimal_point,
168 PyObject **thousands_sep,
169 const char **grouping);
170
Victor Stinner1db9e7b2014-07-29 22:32:47 +0200171#endif /* Py_LIMITED_API */
Victor Stinnerdaf45552013-08-28 00:53:59 +0200172
Victor Stinner4e314432010-10-07 21:45:39 +0000173#ifdef __cplusplus
174}
175#endif
176
177#endif /* !Py_FILEUTILS_H */