blob: b4a683c176c040392c265ba3616d3a16f4ad7da1 [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
Brett Cannonefb00c02012-02-29 18:31:31 -05008PyAPI_FUNC(PyObject *) _Py_device_encoding(int);
9
Victor Stinnerf6a271a2014-08-01 12:28:48 +020010PyAPI_FUNC(wchar_t *) Py_DecodeLocale(
Victor Stinner168e1172010-10-16 23:16:16 +000011 const char *arg,
12 size_t *size);
Victor Stinner4e314432010-10-07 21:45:39 +000013
Victor Stinnerf6a271a2014-08-01 12:28:48 +020014PyAPI_FUNC(char*) Py_EncodeLocale(
Victor Stinner2f02a512010-11-08 22:43:46 +000015 const wchar_t *text,
16 size_t *error_pos);
Victor Stinner4e314432010-10-07 21:45:39 +000017
Serhiy Storchaka12ebbc72015-02-22 19:39:36 +020018#ifndef Py_LIMITED_API
Steve Dowerf2f373f2015-02-21 08:44:05 -080019
20#ifdef MS_WINDOWS
21struct _Py_stat_struct {
22 unsigned long st_dev;
23 __int64 st_ino;
24 unsigned short st_mode;
25 int st_nlink;
26 int st_uid;
27 int st_gid;
28 unsigned long st_rdev;
29 __int64 st_size;
30 time_t st_atime;
31 int st_atime_nsec;
32 time_t st_mtime;
33 int st_mtime_nsec;
34 time_t st_ctime;
35 int st_ctime_nsec;
36 unsigned long st_file_attributes;
37};
38#else
39# define _Py_stat_struct stat
40#endif
41
42PyAPI_FUNC(int) _Py_fstat(
43 int fd,
Victor Stinnere134a7f2015-03-30 10:09:31 +020044 struct _Py_stat_struct *status);
45
46PyAPI_FUNC(int) _Py_fstat_noraise(
47 int fd,
48 struct _Py_stat_struct *status);
Serhiy Storchaka12ebbc72015-02-22 19:39:36 +020049#endif /* Py_LIMITED_API */
Steve Dowerf2f373f2015-02-21 08:44:05 -080050
Victor Stinner4e314432010-10-07 21:45:39 +000051PyAPI_FUNC(int) _Py_stat(
Victor Stinnera4a75952010-10-07 22:23:10 +000052 PyObject *path,
Victor Stinnere134a7f2015-03-30 10:09:31 +020053 struct stat *status);
Victor Stinner4e314432010-10-07 21:45:39 +000054
Martin v. Löwis1c0689c2014-01-03 21:36:49 +010055#ifndef Py_LIMITED_API
Victor Stinnerdaf45552013-08-28 00:53:59 +020056PyAPI_FUNC(int) _Py_open(
57 const char *pathname,
58 int flags);
Victor Stinnera555cfc2015-03-18 00:22:14 +010059
60PyAPI_FUNC(int) _Py_open_noraise(
61 const char *pathname,
62 int flags);
Martin v. Löwis1c0689c2014-01-03 21:36:49 +010063#endif
Victor Stinnerdaf45552013-08-28 00:53:59 +020064
Victor Stinner4e314432010-10-07 21:45:39 +000065PyAPI_FUNC(FILE *) _Py_wfopen(
66 const wchar_t *path,
67 const wchar_t *mode);
68
69PyAPI_FUNC(FILE*) _Py_fopen(
Victor Stinnerdaf45552013-08-28 00:53:59 +020070 const char *pathname,
71 const char *mode);
72
73PyAPI_FUNC(FILE*) _Py_fopen_obj(
Victor Stinnera4a75952010-10-07 22:23:10 +000074 PyObject *path,
Victor Stinner4e314432010-10-07 21:45:39 +000075 const char *mode);
76
Victor Stinner66aab0c2015-03-19 22:53:20 +010077PyAPI_FUNC(Py_ssize_t) _Py_read(
78 int fd,
79 void *buf,
80 size_t count);
81
82PyAPI_FUNC(Py_ssize_t) _Py_write(
83 int fd,
84 const void *buf,
85 size_t count);
86
Victor Stinner82c3e452015-04-01 18:34:45 +020087PyAPI_FUNC(Py_ssize_t) _Py_write_noraise(
88 int fd,
89 const void *buf,
90 size_t count);
91
Victor Stinner4e314432010-10-07 21:45:39 +000092#ifdef HAVE_READLINK
93PyAPI_FUNC(int) _Py_wreadlink(
94 const wchar_t *path,
95 wchar_t *buf,
96 size_t bufsiz);
97#endif
98
99#ifdef HAVE_REALPATH
100PyAPI_FUNC(wchar_t*) _Py_wrealpath(
101 const wchar_t *path,
Victor Stinner015f4d82010-10-07 22:29:53 +0000102 wchar_t *resolved_path,
103 size_t resolved_path_size);
Victor Stinner4e314432010-10-07 21:45:39 +0000104#endif
105
106PyAPI_FUNC(wchar_t*) _Py_wgetcwd(
107 wchar_t *buf,
108 size_t size);
109
Martin v. Löwis1c0689c2014-01-03 21:36:49 +0100110#ifndef Py_LIMITED_API
Victor Stinnerdaf45552013-08-28 00:53:59 +0200111PyAPI_FUNC(int) _Py_get_inheritable(int fd);
112
113PyAPI_FUNC(int) _Py_set_inheritable(int fd, int inheritable,
114 int *atomic_flag_works);
115
116PyAPI_FUNC(int) _Py_dup(int fd);
Victor Stinner1db9e7b2014-07-29 22:32:47 +0200117
118#ifndef MS_WINDOWS
119PyAPI_FUNC(int) _Py_get_blocking(int fd);
120
121PyAPI_FUNC(int) _Py_set_blocking(int fd, int blocking);
122#endif /* !MS_WINDOWS */
123
Steve Dower8fc89802015-04-12 00:26:27 -0400124#if defined _MSC_VER && _MSC_VER >= 1400 && _MSC_VER < 1900
Steve Dowerd81431f2015-03-06 14:47:02 -0800125/* A routine to check if a file descriptor is valid on Windows. Returns 0
126 * and sets errno to EBADF if it isn't. This is to avoid Assertions
127 * from various functions in the Windows CRT beginning with
128 * Visual Studio 2005
129 */
130int _PyVerify_fd(int fd);
131
132#else
133#define _PyVerify_fd(A) (1) /* dummy */
134#endif
135
Victor Stinner1db9e7b2014-07-29 22:32:47 +0200136#endif /* Py_LIMITED_API */
Victor Stinnerdaf45552013-08-28 00:53:59 +0200137
Victor Stinner4e314432010-10-07 21:45:39 +0000138#ifdef __cplusplus
139}
140#endif
141
142#endif /* !Py_FILEUTILS_H */