jpayne@69: #ifndef Py_FILEUTILS_H jpayne@69: #define Py_FILEUTILS_H jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: jpayne@69: #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000 jpayne@69: PyAPI_FUNC(wchar_t *) Py_DecodeLocale( jpayne@69: const char *arg, jpayne@69: size_t *size); jpayne@69: jpayne@69: PyAPI_FUNC(char*) Py_EncodeLocale( jpayne@69: const wchar_t *text, jpayne@69: size_t *error_pos); jpayne@69: jpayne@69: PyAPI_FUNC(char*) _Py_EncodeLocaleRaw( jpayne@69: const wchar_t *text, jpayne@69: size_t *error_pos); jpayne@69: #endif jpayne@69: jpayne@69: jpayne@69: #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03080000 jpayne@69: typedef enum { jpayne@69: _Py_ERROR_UNKNOWN=0, jpayne@69: _Py_ERROR_STRICT, jpayne@69: _Py_ERROR_SURROGATEESCAPE, jpayne@69: _Py_ERROR_REPLACE, jpayne@69: _Py_ERROR_IGNORE, jpayne@69: _Py_ERROR_BACKSLASHREPLACE, jpayne@69: _Py_ERROR_SURROGATEPASS, jpayne@69: _Py_ERROR_XMLCHARREFREPLACE, jpayne@69: _Py_ERROR_OTHER jpayne@69: } _Py_error_handler; jpayne@69: jpayne@69: PyAPI_FUNC(_Py_error_handler) _Py_GetErrorHandler(const char *errors); jpayne@69: jpayne@69: PyAPI_FUNC(int) _Py_DecodeLocaleEx( jpayne@69: const char *arg, jpayne@69: wchar_t **wstr, jpayne@69: size_t *wlen, jpayne@69: const char **reason, jpayne@69: int current_locale, jpayne@69: _Py_error_handler errors); jpayne@69: jpayne@69: PyAPI_FUNC(int) _Py_EncodeLocaleEx( jpayne@69: const wchar_t *text, jpayne@69: char **str, jpayne@69: size_t *error_pos, jpayne@69: const char **reason, jpayne@69: int current_locale, jpayne@69: _Py_error_handler errors); jpayne@69: #endif jpayne@69: jpayne@69: #ifndef Py_LIMITED_API jpayne@69: PyAPI_FUNC(PyObject *) _Py_device_encoding(int); jpayne@69: jpayne@69: #if defined(MS_WINDOWS) || defined(__APPLE__) jpayne@69: /* On Windows, the count parameter of read() is an int (bpo-9015, bpo-9611). jpayne@69: On macOS 10.13, read() and write() with more than INT_MAX bytes jpayne@69: fail with EINVAL (bpo-24658). */ jpayne@69: # define _PY_READ_MAX INT_MAX jpayne@69: # define _PY_WRITE_MAX INT_MAX jpayne@69: #else jpayne@69: /* write() should truncate the input to PY_SSIZE_T_MAX bytes, jpayne@69: but it's safer to do it ourself to have a portable behaviour */ jpayne@69: # define _PY_READ_MAX PY_SSIZE_T_MAX jpayne@69: # define _PY_WRITE_MAX PY_SSIZE_T_MAX jpayne@69: #endif jpayne@69: jpayne@69: #ifdef MS_WINDOWS jpayne@69: struct _Py_stat_struct { jpayne@69: unsigned long st_dev; jpayne@69: uint64_t st_ino; jpayne@69: unsigned short st_mode; jpayne@69: int st_nlink; jpayne@69: int st_uid; jpayne@69: int st_gid; jpayne@69: unsigned long st_rdev; jpayne@69: __int64 st_size; jpayne@69: time_t st_atime; jpayne@69: int st_atime_nsec; jpayne@69: time_t st_mtime; jpayne@69: int st_mtime_nsec; jpayne@69: time_t st_ctime; jpayne@69: int st_ctime_nsec; jpayne@69: unsigned long st_file_attributes; jpayne@69: unsigned long st_reparse_tag; jpayne@69: }; jpayne@69: #else jpayne@69: # define _Py_stat_struct stat jpayne@69: #endif jpayne@69: jpayne@69: PyAPI_FUNC(int) _Py_fstat( jpayne@69: int fd, jpayne@69: struct _Py_stat_struct *status); jpayne@69: jpayne@69: PyAPI_FUNC(int) _Py_fstat_noraise( jpayne@69: int fd, jpayne@69: struct _Py_stat_struct *status); jpayne@69: jpayne@69: PyAPI_FUNC(int) _Py_stat( jpayne@69: PyObject *path, jpayne@69: struct stat *status); jpayne@69: jpayne@69: PyAPI_FUNC(int) _Py_open( jpayne@69: const char *pathname, jpayne@69: int flags); jpayne@69: jpayne@69: PyAPI_FUNC(int) _Py_open_noraise( jpayne@69: const char *pathname, jpayne@69: int flags); jpayne@69: jpayne@69: PyAPI_FUNC(FILE *) _Py_wfopen( jpayne@69: const wchar_t *path, jpayne@69: const wchar_t *mode); jpayne@69: jpayne@69: PyAPI_FUNC(FILE*) _Py_fopen( jpayne@69: const char *pathname, jpayne@69: const char *mode); jpayne@69: jpayne@69: PyAPI_FUNC(FILE*) _Py_fopen_obj( jpayne@69: PyObject *path, jpayne@69: const char *mode); jpayne@69: jpayne@69: PyAPI_FUNC(Py_ssize_t) _Py_read( jpayne@69: int fd, jpayne@69: void *buf, jpayne@69: size_t count); jpayne@69: jpayne@69: PyAPI_FUNC(Py_ssize_t) _Py_write( jpayne@69: int fd, jpayne@69: const void *buf, jpayne@69: size_t count); jpayne@69: jpayne@69: PyAPI_FUNC(Py_ssize_t) _Py_write_noraise( jpayne@69: int fd, jpayne@69: const void *buf, jpayne@69: size_t count); jpayne@69: jpayne@69: #ifdef HAVE_READLINK jpayne@69: PyAPI_FUNC(int) _Py_wreadlink( jpayne@69: const wchar_t *path, jpayne@69: wchar_t *buf, jpayne@69: /* Number of characters of 'buf' buffer jpayne@69: including the trailing NUL character */ jpayne@69: size_t buflen); jpayne@69: #endif jpayne@69: jpayne@69: #ifdef HAVE_REALPATH jpayne@69: PyAPI_FUNC(wchar_t*) _Py_wrealpath( jpayne@69: const wchar_t *path, jpayne@69: wchar_t *resolved_path, jpayne@69: /* Number of characters of 'resolved_path' buffer jpayne@69: including the trailing NUL character */ jpayne@69: size_t resolved_path_len); jpayne@69: #endif jpayne@69: jpayne@69: PyAPI_FUNC(wchar_t*) _Py_wgetcwd( jpayne@69: wchar_t *buf, jpayne@69: /* Number of characters of 'buf' buffer jpayne@69: including the trailing NUL character */ jpayne@69: size_t buflen); jpayne@69: jpayne@69: PyAPI_FUNC(int) _Py_get_inheritable(int fd); jpayne@69: jpayne@69: PyAPI_FUNC(int) _Py_set_inheritable(int fd, int inheritable, jpayne@69: int *atomic_flag_works); jpayne@69: jpayne@69: PyAPI_FUNC(int) _Py_set_inheritable_async_safe(int fd, int inheritable, jpayne@69: int *atomic_flag_works); jpayne@69: jpayne@69: PyAPI_FUNC(int) _Py_dup(int fd); jpayne@69: jpayne@69: #ifndef MS_WINDOWS jpayne@69: PyAPI_FUNC(int) _Py_get_blocking(int fd); jpayne@69: jpayne@69: PyAPI_FUNC(int) _Py_set_blocking(int fd, int blocking); jpayne@69: #endif /* !MS_WINDOWS */ jpayne@69: jpayne@69: #endif /* Py_LIMITED_API */ jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: #endif /* !Py_FILEUTILS_H */