#ifndef SWIFT_IO_FILE_H
#define SWIFT_IO_FILE_H

#include <swift/stdlib.h>

#include <swift/io/api.h>

typedef struct swift_file_t swift_file_t;

#define SWIFT_FILE_SEEK_SET 0
#define SWIFT_FILE_SEEK_CURRENT 1
#define SWIFT_FILE_SEEK_END 2

#define SWIFT_FILE_FLAGS_READ (1 << 0)
#define SWIFT_FILE_FLAGS_WRITE (1 << 1)
#define SWIFT_FILE_FLAGS_APPEND (1 << 2)
#define SWIFT_FILE_FLAGS_TRUNCATE (1 << 3)

SWIFT_IO_API swift_file_t *swift_open_file(const char *path,
	unsigned int flags);
SWIFT_IO_API void swift_close_file(swift_file_t *file);
SWIFT_IO_API int64_t swift_seek_file(swift_file_t *file, unsigned int whence,
	int64_t pos);
SWIFT_IO_API size_t swift_read_file(swift_file_t *file, void *buffer,
	size_t size);
SWIFT_IO_API size_t swift_write_file(swift_file_t *file, const void *buffer,
	size_t size);
SWIFT_IO_API bool swift_flush_file(swift_file_t *file);

#endif /* SWIFT_IO_FILE_H */
