blob: d027e18348fbb347cd69a2707715badf1558888e [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
23PyAPI_FUNC(wchar_t*) _Py_DecodeUTF8_surrogateescape(
24 const char *s,
25 Py_ssize_t size,
26 size_t *p_wlen);
27#endif
28
Serhiy Storchaka12ebbc72015-02-22 19:39:36 +020029#ifndef Py_LIMITED_API
Serhiy Storchaka9fab79b2016-09-11 11:03:14 +030030PyAPI_FUNC(PyObject *) _Py_device_encoding(int);
31
Steve Dowerf2f373f2015-02-21 08:44:05 -080032#ifdef MS_WINDOWS
33struct _Py_stat_struct {
34 unsigned long st_dev;
Victor Stinner0f6d7332017-03-09 17:34:28 +010035 uint64_t st_ino;
Steve Dowerf2f373f2015-02-21 08:44:05 -080036 unsigned short st_mode;
37 int st_nlink;
38 int st_uid;
39 int st_gid;
40 unsigned long st_rdev;
41 __int64 st_size;
42 time_t st_atime;
43 int st_atime_nsec;
44 time_t st_mtime;
45 int st_mtime_nsec;
46 time_t st_ctime;
47 int st_ctime_nsec;
48 unsigned long st_file_attributes;
49};
50#else
51# define _Py_stat_struct stat
52#endif
53
54PyAPI_FUNC(int) _Py_fstat(
55 int fd,
Victor Stinnere134a7f2015-03-30 10:09:31 +020056 struct _Py_stat_struct *status);
57
58PyAPI_FUNC(int) _Py_fstat_noraise(
59 int fd,
60 struct _Py_stat_struct *status);
Steve Dowerf2f373f2015-02-21 08:44:05 -080061
Victor Stinner4e314432010-10-07 21:45:39 +000062PyAPI_FUNC(int) _Py_stat(
Victor Stinnera4a75952010-10-07 22:23:10 +000063 PyObject *path,
Victor Stinnere134a7f2015-03-30 10:09:31 +020064 struct stat *status);
Victor Stinner4e314432010-10-07 21:45:39 +000065
Victor Stinnerdaf45552013-08-28 00:53:59 +020066PyAPI_FUNC(int) _Py_open(
67 const char *pathname,
68 int flags);
Victor Stinnera555cfc2015-03-18 00:22:14 +010069
70PyAPI_FUNC(int) _Py_open_noraise(
71 const char *pathname,
72 int flags);
Victor Stinnerdaf45552013-08-28 00:53:59 +020073
Victor Stinner4e314432010-10-07 21:45:39 +000074PyAPI_FUNC(FILE *) _Py_wfopen(
75 const wchar_t *path,
76 const wchar_t *mode);
77
78PyAPI_FUNC(FILE*) _Py_fopen(
Victor Stinnerdaf45552013-08-28 00:53:59 +020079 const char *pathname,
80 const char *mode);
81
82PyAPI_FUNC(FILE*) _Py_fopen_obj(
Victor Stinnera4a75952010-10-07 22:23:10 +000083 PyObject *path,
Victor Stinner4e314432010-10-07 21:45:39 +000084 const char *mode);
85
Victor Stinner66aab0c2015-03-19 22:53:20 +010086PyAPI_FUNC(Py_ssize_t) _Py_read(
87 int fd,
88 void *buf,
89 size_t count);
90
91PyAPI_FUNC(Py_ssize_t) _Py_write(
92 int fd,
93 const void *buf,
94 size_t count);
95
Victor Stinner82c3e452015-04-01 18:34:45 +020096PyAPI_FUNC(Py_ssize_t) _Py_write_noraise(
97 int fd,
98 const void *buf,
99 size_t count);
100
Victor Stinner4e314432010-10-07 21:45:39 +0000101#ifdef HAVE_READLINK
102PyAPI_FUNC(int) _Py_wreadlink(
103 const wchar_t *path,
104 wchar_t *buf,
105 size_t bufsiz);
106#endif
107
108#ifdef HAVE_REALPATH
109PyAPI_FUNC(wchar_t*) _Py_wrealpath(
110 const wchar_t *path,
Victor Stinner015f4d82010-10-07 22:29:53 +0000111 wchar_t *resolved_path,
112 size_t resolved_path_size);
Victor Stinner4e314432010-10-07 21:45:39 +0000113#endif
114
115PyAPI_FUNC(wchar_t*) _Py_wgetcwd(
116 wchar_t *buf,
117 size_t size);
118
Victor Stinnerdaf45552013-08-28 00:53:59 +0200119PyAPI_FUNC(int) _Py_get_inheritable(int fd);
120
121PyAPI_FUNC(int) _Py_set_inheritable(int fd, int inheritable,
122 int *atomic_flag_works);
123
124PyAPI_FUNC(int) _Py_dup(int fd);
Victor Stinner1db9e7b2014-07-29 22:32:47 +0200125
126#ifndef MS_WINDOWS
127PyAPI_FUNC(int) _Py_get_blocking(int fd);
128
129PyAPI_FUNC(int) _Py_set_blocking(int fd, int blocking);
130#endif /* !MS_WINDOWS */
131
132#endif /* Py_LIMITED_API */
Victor Stinnerdaf45552013-08-28 00:53:59 +0200133
Victor Stinner4e314432010-10-07 21:45:39 +0000134#ifdef __cplusplus
135}
136#endif
137
138#endif /* !Py_FILEUTILS_H */