2021-08-08 04:08:33 +00:00
|
|
|
#ifndef Py_FILEUTILS_H
|
|
|
|
#define Py_FILEUTILS_H
|
2021-08-12 07:42:14 +00:00
|
|
|
#include "libc/calls/struct/stat.h"
|
|
|
|
#include "third_party/python/Include/object.h"
|
2021-08-10 17:26:13 +00:00
|
|
|
COSMOPOLITAN_C_START_
|
|
|
|
/* clang-format off */
|
2021-08-08 04:08:33 +00:00
|
|
|
|
|
|
|
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
|
2021-08-12 07:42:14 +00:00
|
|
|
wchar_t * Py_DecodeLocale(
|
2021-08-08 04:08:33 +00:00
|
|
|
const char *arg,
|
|
|
|
size_t *size);
|
|
|
|
|
2021-08-12 07:42:14 +00:00
|
|
|
char* Py_EncodeLocale(
|
2021-08-08 04:08:33 +00:00
|
|
|
const wchar_t *text,
|
|
|
|
size_t *error_pos);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef Py_LIMITED_API
|
|
|
|
|
2021-08-12 07:42:14 +00:00
|
|
|
wchar_t * _Py_DecodeLocaleEx(
|
2021-08-08 04:08:33 +00:00
|
|
|
const char *arg,
|
|
|
|
size_t *size,
|
|
|
|
int current_locale);
|
|
|
|
|
2021-08-12 07:42:14 +00:00
|
|
|
char* _Py_EncodeLocaleEx(
|
2021-08-08 04:08:33 +00:00
|
|
|
const wchar_t *text,
|
|
|
|
size_t *error_pos,
|
|
|
|
int current_locale);
|
|
|
|
|
2021-08-12 07:42:14 +00:00
|
|
|
PyObject * _Py_device_encoding(int);
|
2021-08-08 04:08:33 +00:00
|
|
|
|
|
|
|
#if defined(MS_WINDOWS) || defined(__APPLE__)
|
|
|
|
/* On Windows, the count parameter of read() is an int (bpo-9015, bpo-9611).
|
|
|
|
On macOS 10.13, read() and write() with more than INT_MAX bytes
|
|
|
|
fail with EINVAL (bpo-24658). */
|
|
|
|
# define _PY_READ_MAX INT_MAX
|
|
|
|
# define _PY_WRITE_MAX INT_MAX
|
|
|
|
#else
|
|
|
|
/* write() should truncate the input to PY_SSIZE_T_MAX bytes,
|
|
|
|
but it's safer to do it ourself to have a portable behaviour */
|
|
|
|
# define _PY_READ_MAX PY_SSIZE_T_MAX
|
|
|
|
# define _PY_WRITE_MAX PY_SSIZE_T_MAX
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef MS_WINDOWS
|
|
|
|
struct _Py_stat_struct {
|
|
|
|
unsigned long st_dev;
|
|
|
|
uint64_t st_ino;
|
|
|
|
unsigned short st_mode;
|
|
|
|
int st_nlink;
|
|
|
|
int st_uid;
|
|
|
|
int st_gid;
|
|
|
|
unsigned long st_rdev;
|
|
|
|
__int64 st_size;
|
|
|
|
time_t st_atime;
|
|
|
|
int st_atime_nsec;
|
|
|
|
time_t st_mtime;
|
|
|
|
int st_mtime_nsec;
|
|
|
|
time_t st_ctime;
|
|
|
|
int st_ctime_nsec;
|
|
|
|
unsigned long st_file_attributes;
|
|
|
|
};
|
|
|
|
#else
|
|
|
|
# define _Py_stat_struct stat
|
|
|
|
#endif
|
|
|
|
|
2021-08-12 07:42:14 +00:00
|
|
|
int _Py_fstat(
|
2021-08-08 04:08:33 +00:00
|
|
|
int fd,
|
|
|
|
struct _Py_stat_struct *status);
|
|
|
|
|
2021-08-12 07:42:14 +00:00
|
|
|
int _Py_fstat_noraise(
|
2021-08-08 04:08:33 +00:00
|
|
|
int fd,
|
|
|
|
struct _Py_stat_struct *status);
|
|
|
|
|
2021-08-12 07:42:14 +00:00
|
|
|
int _Py_stat(
|
2021-08-08 04:08:33 +00:00
|
|
|
PyObject *path,
|
|
|
|
struct stat *status);
|
|
|
|
|
2021-08-12 07:42:14 +00:00
|
|
|
int _Py_open(
|
2021-08-08 04:08:33 +00:00
|
|
|
const char *pathname,
|
|
|
|
int flags);
|
|
|
|
|
2021-08-12 07:42:14 +00:00
|
|
|
int _Py_open_noraise(
|
2021-08-08 04:08:33 +00:00
|
|
|
const char *pathname,
|
|
|
|
int flags);
|
|
|
|
|
2021-08-12 07:42:14 +00:00
|
|
|
FILE * _Py_wfopen(
|
2021-08-08 04:08:33 +00:00
|
|
|
const wchar_t *path,
|
|
|
|
const wchar_t *mode);
|
|
|
|
|
2021-08-12 07:42:14 +00:00
|
|
|
FILE* _Py_fopen(
|
2021-08-08 04:08:33 +00:00
|
|
|
const char *pathname,
|
|
|
|
const char *mode);
|
|
|
|
|
2021-08-12 07:42:14 +00:00
|
|
|
FILE* _Py_fopen_obj(
|
2021-08-08 04:08:33 +00:00
|
|
|
PyObject *path,
|
|
|
|
const char *mode);
|
|
|
|
|
2021-08-12 07:42:14 +00:00
|
|
|
Py_ssize_t _Py_read(
|
2021-08-08 04:08:33 +00:00
|
|
|
int fd,
|
|
|
|
void *buf,
|
|
|
|
size_t count);
|
|
|
|
|
2021-08-12 07:42:14 +00:00
|
|
|
Py_ssize_t _Py_write(
|
2021-08-08 04:08:33 +00:00
|
|
|
int fd,
|
|
|
|
const void *buf,
|
|
|
|
size_t count);
|
|
|
|
|
2021-08-12 07:42:14 +00:00
|
|
|
Py_ssize_t _Py_write_noraise(
|
2021-08-08 04:08:33 +00:00
|
|
|
int fd,
|
|
|
|
const void *buf,
|
|
|
|
size_t count);
|
|
|
|
|
|
|
|
#ifdef HAVE_READLINK
|
2021-08-12 07:42:14 +00:00
|
|
|
int _Py_wreadlink(
|
2021-08-08 04:08:33 +00:00
|
|
|
const wchar_t *path,
|
|
|
|
wchar_t *buf,
|
|
|
|
size_t bufsiz);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_REALPATH
|
2021-08-12 07:42:14 +00:00
|
|
|
wchar_t* _Py_wrealpath(
|
2021-08-08 04:08:33 +00:00
|
|
|
const wchar_t *path,
|
|
|
|
wchar_t *resolved_path,
|
|
|
|
size_t resolved_path_size);
|
|
|
|
#endif
|
|
|
|
|
2021-08-12 07:42:14 +00:00
|
|
|
wchar_t* _Py_wgetcwd(
|
2021-08-08 04:08:33 +00:00
|
|
|
wchar_t *buf,
|
|
|
|
size_t size);
|
|
|
|
|
2021-08-12 07:42:14 +00:00
|
|
|
int _Py_get_inheritable(int fd);
|
2021-08-08 04:08:33 +00:00
|
|
|
|
2021-08-12 07:42:14 +00:00
|
|
|
int _Py_set_inheritable(int fd, int inheritable,
|
2021-08-08 04:08:33 +00:00
|
|
|
int *atomic_flag_works);
|
|
|
|
|
2021-08-12 07:42:14 +00:00
|
|
|
int _Py_set_inheritable_async_safe(int fd, int inheritable,
|
2021-08-08 04:08:33 +00:00
|
|
|
int *atomic_flag_works);
|
|
|
|
|
2021-08-12 07:42:14 +00:00
|
|
|
int _Py_dup(int fd);
|
2021-08-08 04:08:33 +00:00
|
|
|
|
|
|
|
#ifndef MS_WINDOWS
|
2021-08-12 07:42:14 +00:00
|
|
|
int _Py_get_blocking(int fd);
|
2021-08-08 04:08:33 +00:00
|
|
|
|
2021-08-12 07:42:14 +00:00
|
|
|
int _Py_set_blocking(int fd, int blocking);
|
2021-08-08 04:08:33 +00:00
|
|
|
#endif /* !MS_WINDOWS */
|
|
|
|
|
2021-08-12 07:42:14 +00:00
|
|
|
int _Py_GetLocaleconvNumeric(
|
2021-08-08 04:08:33 +00:00
|
|
|
PyObject **decimal_point,
|
|
|
|
PyObject **thousands_sep,
|
|
|
|
const char **grouping);
|
|
|
|
|
|
|
|
#endif /* Py_LIMITED_API */
|
|
|
|
|
2021-08-10 17:26:13 +00:00
|
|
|
COSMOPOLITAN_C_END_
|
2021-08-08 04:08:33 +00:00
|
|
|
#endif /* !Py_FILEUTILS_H */
|