Lely core libraries  2.3.4
file.h
Go to the documentation of this file.
1 
22 #ifndef LELY_IO_FILE_H_
23 #define LELY_IO_FILE_H_
24 
25 #include <lely/io/io.h>
26 
27 enum {
29  IO_FILE_READ = 1 << 0,
31  IO_FILE_WRITE = 1 << 1,
33  IO_FILE_APPEND = 1 << 2,
35  IO_FILE_CREATE = 1 << 3,
40  IO_FILE_NO_EXIST = 1 << 4,
43 };
44 
45 enum {
52 };
53 
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57 
69 io_handle_t io_open_file(const char *path, int flags);
70 
85 io_off_t io_seek(io_handle_t handle, io_off_t offset, int whence);
86 
99 ssize_t io_pread(io_handle_t handle, void *buf, size_t nbytes, io_off_t offset);
100 
113 ssize_t io_pwrite(io_handle_t handle, const void *buf, size_t nbytes,
114  io_off_t offset);
115 
116 #ifdef __cplusplus
117 }
118 #endif
119 
120 #endif // !LELY_IO_FILE_H_
IO_FILE_READ
@ IO_FILE_READ
Open a file for reading.
Definition: file.h:29
IO_FILE_APPEND
@ IO_FILE_APPEND
Append data to the end of the file.
Definition: file.h:33
IO_FILE_CREATE
@ IO_FILE_CREATE
Create a new file if it does not exists.
Definition: file.h:35
io_open_file
io_handle_t io_open_file(const char *path, int flags)
Opens a regular file.
Definition: file.c:81
IO_FILE_NO_EXIST
@ IO_FILE_NO_EXIST
Fail if the file already exists (ignored unless IO_FILE_CREATE is set).
Definition: file.h:40
IO_FILE_WRITE
@ IO_FILE_WRITE
Open a file for writing.
Definition: file.h:31
io_off_t
int64_t io_off_t
A file offset type.
Definition: io.h:37
IO_FILE_TRUNCATE
@ IO_FILE_TRUNCATE
Truncate an existing file (ignored if IO_FILE_NO_EXIST is set).
Definition: file.h:42
io_handle
An I/O device handle.
Definition: handle.h:33
io.h
io_seek
io_off_t io_seek(io_handle_t handle, io_off_t offset, int whence)
Moves the current read/write offset of an open file.
Definition: file.c:185
IO_SEEK_END
@ IO_SEEK_END
A seek operation with respect to the end of a file.
Definition: file.h:51
IO_SEEK_CURRENT
@ IO_SEEK_CURRENT
A seek operation with respect to the current offset in a file.
Definition: file.h:49
IO_SEEK_BEGIN
@ IO_SEEK_BEGIN
A seek operation with respect to the beginning of a file.
Definition: file.h:47
io_pwrite
ssize_t io_pwrite(io_handle_t handle, const void *buf, size_t nbytes, io_off_t offset)
Performs a write operation at the specified offset, without updating the file pointer.
Definition: file.c:219
io_pread
ssize_t io_pread(io_handle_t handle, void *buf, size_t nbytes, io_off_t offset)
Performs a read operation at the specified offset, without updating the file pointer.
Definition: file.c:202