22 #ifndef XAPIAN_INCLUDED_IO_UTILS_H 23 #define XAPIAN_INCLUDED_IO_UTILS_H 26 # error config.h must be included first in each C++ source file 29 #include <sys/types.h> 75 #if defined HAVE_FDATASYNC 78 return fdatasync(fd) == 0;
79 #elif defined HAVE_FSYNC 80 return fsync(fd) == 0;
81 #elif defined __WIN32__ 82 return _commit(fd) == 0;
84 # error Cannot implement io_sync() without fdatasync(), fsync(), or _commit() 101 if (fcntl(fd, F_FULLFSYNC, 0) == 0)
117 size_t io_read(
int fd,
char * p,
size_t n,
size_t min = 0);
120 void io_write(
int fd,
const char * p,
size_t n);
122 inline void io_write(
int fd,
const unsigned char * p,
size_t n) {
123 io_write(fd, reinterpret_cast<const char *>(p), n);
130 #ifdef HAVE_POSIX_FADVISE 137 void io_read_block(
int fd,
char * p,
size_t n, off_t b, off_t o = 0);
140 void io_write_block(
int fd,
const char * p,
size_t n, off_t b, off_t o = 0);
158 bool io_unlink(
const std::string & filename);
168 bool io_tmp_rename(
const std::string & tmp_file,
const std::string & real_file);
170 #endif // XAPIAN_INCLUDED_IO_UTILS_H bool io_unlink(const std::string &filename)
Delete a file.
int io_open_block_rd(const char *fname)
Open a block-based file for reading.
void io_write_block(int fd, const char *p, size_t n, off_t b, off_t o=0)
Write block b size n bytes from buffer p to file descriptor fd, offset o.
size_t io_read(int fd, char *p, size_t n, size_t min=0)
Read n bytes (or until EOF) into block pointed to by p from file descriptor fd.
void io_read_block(int fd, char *p, size_t n, off_t b, off_t o=0)
Read block b size n bytes into buffer p from file descriptor fd, offset o.
bool io_sync(int fd)
Ensure all data previously written to file descriptor fd has been written to disk.
WritableDatabase open()
Construct a WritableDatabase object for a new, empty InMemory database.
bool io_readahead_block(int, size_t, off_t, off_t=0)
Readahead block b size n bytes from file descriptor fd.
int io_open_block_wr(const char *fname, bool anew)
Open a block-based file for writing.
bool io_full_sync(int fd)
bool io_tmp_rename(const std::string &tmp_file, const std::string &real_file)
Rename a temporary file to its final position.
<unistd.h>, but with compat.
void io_write(int fd, const char *p, size_t n)
Write n bytes from block pointed to by p to file descriptor fd.
include <fcntl.h>, but working around broken platforms.