xapian-core
1.4.27
|
Wrappers for low-level POSIX I/O routines. More...
Go to the source code of this file.
Functions | |
int | io_open_block_rd (const char *fname) |
Open a block-based file for reading. More... | |
int | io_open_block_rd (const std::string &fname) |
Open a block-based file for reading. More... | |
int | io_open_block_wr (const char *fname, bool anew) |
Open a block-based file for writing. More... | |
int | io_open_block_wr (const std::string &fname, bool anew) |
Open a block-based file for writing. More... | |
bool | io_sync (int fd) |
Ensure all data previously written to file descriptor fd has been written to disk. More... | |
bool | io_full_sync (int fd) |
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. More... | |
void | io_write (int fd, const char *p, size_t n) |
Write n bytes from block pointed to by p to file descriptor fd. More... | |
void | io_write (int fd, const unsigned char *p, size_t n) |
bool | io_readahead_block (int, size_t, off_t, off_t=0) |
Readahead block b size n bytes from file descriptor fd. More... | |
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. More... | |
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. More... | |
void | io_write_block (int fd, const unsigned char *p, size_t n, off_t b) |
bool | io_unlink (const std::string &filename) |
Delete a file. More... | |
bool | io_tmp_rename (const std::string &tmp_file, const std::string &real_file) |
Rename a temporary file to its final position. More... | |
Wrappers for low-level POSIX I/O routines.
Definition in file io_utils.h.
|
inline |
Definition at line 88 of file io_utils.h.
References io_read(), io_sync(), and io_write().
Referenced by ChertTable::commit(), GlassVersion::sync(), and test_ioblock1().
|
inline |
Open a block-based file for reading.
fname | The path of the file to open. |
Definition at line 38 of file io_utils.h.
References O_BINARY, O_CLOEXEC, and Xapian::InMemory::open().
Referenced by GlassTable::do_open_to_read(), ChertTable::do_open_to_read(), io_open_block_rd(), and test_ioblock1().
|
inline |
Open a block-based file for reading.
fname | The path of the file to open. |
Definition at line 46 of file io_utils.h.
References io_open_block_rd(), and io_open_block_wr().
int io_open_block_wr | ( | const char * | fname, |
bool | anew | ||
) |
Open a block-based file for writing.
fname | The path of the file to open. |
anew | If true, open the file anew (create or truncate it). |
Definition at line 67 of file io_utils.cc.
References Assert, close(), MIN_WRITE_FD, O_BINARY, O_CLOEXEC, and Xapian::InMemory::open().
Referenced by GlassTable::do_open_to_write(), ChertTable::do_open_to_write(), io_open_block_rd(), io_open_block_wr(), and test_ioblock1().
|
inline |
Open a block-based file for writing.
fname | The path of the file to open. |
anew | If true, open the file anew (create or truncate it). |
Definition at line 63 of file io_utils.h.
References io_open_block_wr().
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.
If a read error occurs, throws DatabaseError.
If min is specified and EOF is reached after less than min bytes, throws DatabaseCorruptError.
Returns the number of bytes actually read.
Definition at line 123 of file io_utils.cc.
Referenced by ChertTableCheck::check(), GlassChanges::check(), GlassDatabase::get_changeset_revisions(), ChertDatabase::get_changeset_revisions(), io_full_sync(), ChertTable_base::read(), GlassVersion::read(), ChertVersion::read_and_check(), and test_if_single_file_db().
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.
Definition at line 180 of file io_utils.cc.
References rare, throw_block_error(), and usual.
Referenced by io_readahead_block(), ChertTable::read_block(), GlassTable::read_block(), and test_ioblock1().
|
inline |
Readahead block b size n bytes from file descriptor fd.
Returns false if we can't readahead on this fd.
Definition at line 133 of file io_utils.h.
References io_read_block(), and io_write_block().
Referenced by io_write(), ChertTable::readahead_key(), GlassTable::readahead_key(), test_ioblock1(), and throw_block_error().
|
inline |
Ensure all data previously written to file descriptor fd has been written to disk.
Returns false if this could not be done.
Definition at line 73 of file io_utils.h.
Referenced by GlassDatabaseReplicator::commit(), GlassChanges::commit(), ChertTable::commit(), ChertVersion::create(), io_full_sync(), ChertDatabaseReplicator::process_changeset_chunk_base(), ChertDatabaseReplicator::process_changeset_chunk_blocks(), GlassDatabaseReplicator::process_changeset_chunk_version(), GlassVersion::sync(), GlassTable::sync(), test_ioblock1(), and ChertTable_base::write_to_file().
bool io_tmp_rename | ( | const std::string & | tmp_file, |
const std::string & | real_file | ||
) |
Rename a temporary file to its final position.
Attempts to deal with NFS infelicities. If the rename fails, the temporary file is removed.
Definition at line 271 of file io_utils.cc.
References posixy_rename.
Referenced by GlassChanges::commit(), ChertTable::commit(), Xapian::Database::compact_(), io_write_block(), ChertDatabaseReplicator::process_changeset_chunk_base(), GlassDatabaseReplicator::process_changeset_chunk_version(), GlassVersion::sync(), and Xapian::DatabaseReplica::Internal::update_stub_database().
bool io_unlink | ( | const std::string & | filename | ) |
Delete a file.
filename | The file to delete. |
Xapian::DatabaseError | is thrown if filename existed but couldn't be unlinked. |
Definition at line 52 of file io_utils.cc.
References posixy_unlink.
Referenced by GlassChanges::commit(), ChertTable::create_and_open(), GlassTable::create_and_open(), ChertTable::erase(), io_write_block(), ChertDatabase::set_revision_number(), test_ioblock1(), ChertTable::write_block(), and GlassChanges::~GlassChanges().
void io_write | ( | int | fd, |
const char * | p, | ||
size_t | n | ||
) |
Write n bytes from block pointed to by p to file descriptor fd.
Definition at line 145 of file io_utils.cc.
References throw_block_error().
Referenced by GlassChanges::commit(), ChertVersion::create(), io_full_sync(), io_write(), ChertDatabaseReplicator::process_changeset_chunk_base(), GlassDatabaseReplicator::process_changeset_chunk_version(), ChertDatabase::set_revision_number(), GlassChanges::start(), GlassVersion::write(), write_and_clear_changes(), GlassChanges::write_block(), ChertTable::write_changed_blocks(), and ChertTable_base::write_to_file().
|
inline |
Definition at line 122 of file io_utils.h.
References io_readahead_block(), and io_write().
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.
Definition at line 228 of file io_utils.cc.
References rare, throw_block_error(), and usual.
Referenced by io_readahead_block(), io_write_block(), GlassDatabaseReplicator::process_changeset_chunk_blocks(), ChertDatabaseReplicator::process_changeset_chunk_blocks(), test_ioblock1(), ChertTable::write_block(), and GlassTable::write_block().
|
inline |
Definition at line 142 of file io_utils.h.
References io_tmp_rename(), io_unlink(), and io_write_block().