Victor Stinner | 4e31443 | 2010-10-07 21:45:39 +0000 | [diff] [blame] | 1 | #ifndef Py_FILEUTILS_H |
| 2 | #define Py_FILEUTILS_H |
| 3 | |
| 4 | #ifdef __cplusplus |
| 5 | extern "C" { |
| 6 | #endif |
| 7 | |
Serhiy Storchaka | 34d0ac8 | 2016-12-27 14:57:39 +0200 | [diff] [blame] | 8 | #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000 |
Victor Stinner | f6a271a | 2014-08-01 12:28:48 +0200 | [diff] [blame] | 9 | PyAPI_FUNC(wchar_t *) Py_DecodeLocale( |
Victor Stinner | 168e117 | 2010-10-16 23:16:16 +0000 | [diff] [blame] | 10 | const char *arg, |
| 11 | size_t *size); |
Victor Stinner | 4e31443 | 2010-10-07 21:45:39 +0000 | [diff] [blame] | 12 | |
Victor Stinner | f6a271a | 2014-08-01 12:28:48 +0200 | [diff] [blame] | 13 | PyAPI_FUNC(char*) Py_EncodeLocale( |
Victor Stinner | 2f02a51 | 2010-11-08 22:43:46 +0000 | [diff] [blame] | 14 | const wchar_t *text, |
| 15 | size_t *error_pos); |
Victor Stinner | 9dd7620 | 2017-12-21 16:20:32 +0100 | [diff] [blame] | 16 | |
| 17 | PyAPI_FUNC(char*) _Py_EncodeLocaleRaw( |
| 18 | const wchar_t *text, |
| 19 | size_t *error_pos); |
Serhiy Storchaka | 34d0ac8 | 2016-12-27 14:57:39 +0200 | [diff] [blame] | 20 | #endif |
Victor Stinner | 4e31443 | 2010-10-07 21:45:39 +0000 | [diff] [blame] | 21 | |
Victor Stinner | 9bee329 | 2017-12-21 16:49:13 +0100 | [diff] [blame] | 22 | #ifdef Py_BUILD_CORE |
Victor Stinner | 7ed7aea | 2018-01-15 10:45:49 +0100 | [diff] [blame] | 23 | PyAPI_FUNC(int) _Py_DecodeUTF8Ex( |
Victor Stinner | 2cba6b8 | 2018-01-10 22:46:15 +0100 | [diff] [blame] | 24 | const char *arg, |
Victor Stinner | 7ed7aea | 2018-01-15 10:45:49 +0100 | [diff] [blame] | 25 | Py_ssize_t arglen, |
| 26 | wchar_t **wstr, |
| 27 | size_t *wlen, |
| 28 | const char **reason, |
| 29 | int surrogateescape); |
Victor Stinner | 2cba6b8 | 2018-01-10 22:46:15 +0100 | [diff] [blame] | 30 | |
Victor Stinner | 7ed7aea | 2018-01-15 10:45:49 +0100 | [diff] [blame] | 31 | PyAPI_FUNC(int) _Py_EncodeUTF8Ex( |
Victor Stinner | 2cba6b8 | 2018-01-10 22:46:15 +0100 | [diff] [blame] | 32 | const wchar_t *text, |
Victor Stinner | 7ed7aea | 2018-01-15 10:45:49 +0100 | [diff] [blame] | 33 | char **str, |
| 34 | size_t *error_pos, |
| 35 | const char **reason, |
| 36 | int raw_malloc, |
| 37 | int surrogateescape); |
| 38 | |
| 39 | PyAPI_FUNC(wchar_t*) _Py_DecodeUTF8_surrogateescape( |
| 40 | const char *arg, |
| 41 | Py_ssize_t arglen); |
| 42 | |
| 43 | PyAPI_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 | |
| 51 | PyAPI_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 Stinner | 9bee329 | 2017-12-21 16:49:13 +0100 | [diff] [blame] | 58 | #endif |
| 59 | |
Serhiy Storchaka | 12ebbc7 | 2015-02-22 19:39:36 +0200 | [diff] [blame] | 60 | #ifndef Py_LIMITED_API |
Serhiy Storchaka | 9fab79b | 2016-09-11 11:03:14 +0300 | [diff] [blame] | 61 | PyAPI_FUNC(PyObject *) _Py_device_encoding(int); |
| 62 | |
Steve Dower | f2f373f | 2015-02-21 08:44:05 -0800 | [diff] [blame] | 63 | #ifdef MS_WINDOWS |
| 64 | struct _Py_stat_struct { |
| 65 | unsigned long st_dev; |
Victor Stinner | 0f6d733 | 2017-03-09 17:34:28 +0100 | [diff] [blame] | 66 | uint64_t st_ino; |
Steve Dower | f2f373f | 2015-02-21 08:44:05 -0800 | [diff] [blame] | 67 | 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 | |
| 85 | PyAPI_FUNC(int) _Py_fstat( |
| 86 | int fd, |
Victor Stinner | e134a7f | 2015-03-30 10:09:31 +0200 | [diff] [blame] | 87 | struct _Py_stat_struct *status); |
| 88 | |
| 89 | PyAPI_FUNC(int) _Py_fstat_noraise( |
| 90 | int fd, |
| 91 | struct _Py_stat_struct *status); |
Steve Dower | f2f373f | 2015-02-21 08:44:05 -0800 | [diff] [blame] | 92 | |
Victor Stinner | 4e31443 | 2010-10-07 21:45:39 +0000 | [diff] [blame] | 93 | PyAPI_FUNC(int) _Py_stat( |
Victor Stinner | a4a7595 | 2010-10-07 22:23:10 +0000 | [diff] [blame] | 94 | PyObject *path, |
Victor Stinner | e134a7f | 2015-03-30 10:09:31 +0200 | [diff] [blame] | 95 | struct stat *status); |
Victor Stinner | 4e31443 | 2010-10-07 21:45:39 +0000 | [diff] [blame] | 96 | |
Victor Stinner | daf4555 | 2013-08-28 00:53:59 +0200 | [diff] [blame] | 97 | PyAPI_FUNC(int) _Py_open( |
| 98 | const char *pathname, |
| 99 | int flags); |
Victor Stinner | a555cfc | 2015-03-18 00:22:14 +0100 | [diff] [blame] | 100 | |
| 101 | PyAPI_FUNC(int) _Py_open_noraise( |
| 102 | const char *pathname, |
| 103 | int flags); |
Victor Stinner | daf4555 | 2013-08-28 00:53:59 +0200 | [diff] [blame] | 104 | |
Victor Stinner | 4e31443 | 2010-10-07 21:45:39 +0000 | [diff] [blame] | 105 | PyAPI_FUNC(FILE *) _Py_wfopen( |
| 106 | const wchar_t *path, |
| 107 | const wchar_t *mode); |
| 108 | |
| 109 | PyAPI_FUNC(FILE*) _Py_fopen( |
Victor Stinner | daf4555 | 2013-08-28 00:53:59 +0200 | [diff] [blame] | 110 | const char *pathname, |
| 111 | const char *mode); |
| 112 | |
| 113 | PyAPI_FUNC(FILE*) _Py_fopen_obj( |
Victor Stinner | a4a7595 | 2010-10-07 22:23:10 +0000 | [diff] [blame] | 114 | PyObject *path, |
Victor Stinner | 4e31443 | 2010-10-07 21:45:39 +0000 | [diff] [blame] | 115 | const char *mode); |
| 116 | |
Victor Stinner | 66aab0c | 2015-03-19 22:53:20 +0100 | [diff] [blame] | 117 | PyAPI_FUNC(Py_ssize_t) _Py_read( |
| 118 | int fd, |
| 119 | void *buf, |
| 120 | size_t count); |
| 121 | |
| 122 | PyAPI_FUNC(Py_ssize_t) _Py_write( |
| 123 | int fd, |
| 124 | const void *buf, |
| 125 | size_t count); |
| 126 | |
Victor Stinner | 82c3e45 | 2015-04-01 18:34:45 +0200 | [diff] [blame] | 127 | PyAPI_FUNC(Py_ssize_t) _Py_write_noraise( |
| 128 | int fd, |
| 129 | const void *buf, |
| 130 | size_t count); |
| 131 | |
Victor Stinner | 4e31443 | 2010-10-07 21:45:39 +0000 | [diff] [blame] | 132 | #ifdef HAVE_READLINK |
| 133 | PyAPI_FUNC(int) _Py_wreadlink( |
| 134 | const wchar_t *path, |
| 135 | wchar_t *buf, |
| 136 | size_t bufsiz); |
| 137 | #endif |
| 138 | |
| 139 | #ifdef HAVE_REALPATH |
| 140 | PyAPI_FUNC(wchar_t*) _Py_wrealpath( |
| 141 | const wchar_t *path, |
Victor Stinner | 015f4d8 | 2010-10-07 22:29:53 +0000 | [diff] [blame] | 142 | wchar_t *resolved_path, |
| 143 | size_t resolved_path_size); |
Victor Stinner | 4e31443 | 2010-10-07 21:45:39 +0000 | [diff] [blame] | 144 | #endif |
| 145 | |
| 146 | PyAPI_FUNC(wchar_t*) _Py_wgetcwd( |
| 147 | wchar_t *buf, |
| 148 | size_t size); |
| 149 | |
Victor Stinner | daf4555 | 2013-08-28 00:53:59 +0200 | [diff] [blame] | 150 | PyAPI_FUNC(int) _Py_get_inheritable(int fd); |
| 151 | |
| 152 | PyAPI_FUNC(int) _Py_set_inheritable(int fd, int inheritable, |
| 153 | int *atomic_flag_works); |
| 154 | |
Alexey Izbyshev | c1e46e9 | 2018-02-06 09:09:34 +0300 | [diff] [blame] | 155 | PyAPI_FUNC(int) _Py_set_inheritable_async_safe(int fd, int inheritable, |
| 156 | int *atomic_flag_works); |
| 157 | |
Victor Stinner | daf4555 | 2013-08-28 00:53:59 +0200 | [diff] [blame] | 158 | PyAPI_FUNC(int) _Py_dup(int fd); |
Victor Stinner | 1db9e7b | 2014-07-29 22:32:47 +0200 | [diff] [blame] | 159 | |
| 160 | #ifndef MS_WINDOWS |
| 161 | PyAPI_FUNC(int) _Py_get_blocking(int fd); |
| 162 | |
| 163 | PyAPI_FUNC(int) _Py_set_blocking(int fd, int blocking); |
| 164 | #endif /* !MS_WINDOWS */ |
| 165 | |
Victor Stinner | cb064fc | 2018-01-15 15:58:02 +0100 | [diff] [blame] | 166 | PyAPI_FUNC(int) _Py_GetLocaleconvNumeric( |
| 167 | PyObject **decimal_point, |
| 168 | PyObject **thousands_sep, |
| 169 | const char **grouping); |
| 170 | |
Victor Stinner | 1db9e7b | 2014-07-29 22:32:47 +0200 | [diff] [blame] | 171 | #endif /* Py_LIMITED_API */ |
Victor Stinner | daf4555 | 2013-08-28 00:53:59 +0200 | [diff] [blame] | 172 | |
Victor Stinner | 4e31443 | 2010-10-07 21:45:39 +0000 | [diff] [blame] | 173 | #ifdef __cplusplus |
| 174 | } |
| 175 | #endif |
| 176 | |
| 177 | #endif /* !Py_FILEUTILS_H */ |