|
xapian-core
1.4.30
|
Wrappers for low-level POSIX I/O routines. More...
#include <config.h>#include "io_utils.h"#include "posixy_wrapper.h"#include "safeunistd.h"#include <cerrno>#include <cstring>#include <string>#include <xapian/error.h>#include "noreturn.h"#include "omassert.h"#include "str.h"
Include dependency graph for io_utils.cc:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Functions | |
| bool | io_unlink (const std::string &filename) |
| Delete a file. More... | |
| static int | move_to_higher_fd_ (int fd) |
| static int | move_to_higher_fd (int fd) |
| int | io_open_block_wr (const char *filename, bool anew) |
| Open a block-based file for writing. More... | |
| size_t | io_read (int fd, char *p, size_t n, size_t min) |
| 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... | |
| static void | throw_block_error (const char *s, off_t b, int e=0) |
| void | io_read_block (int fd, char *p, size_t n, off_t b, off_t o) |
| 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) |
| Write block b size n bytes from buffer p to file descriptor fd, offset o. More... | |
| bool | io_tmp_rename (const std::string &tmp_file, const std::string &real_file) |
| Rename a temporary file to its final position. More... | |
Variables | |
| const int | MIN_WRITE_FD = 3 |
Wrappers for low-level POSIX I/O routines.
Definition in file io_utils.cc.
| int io_open_block_wr | ( | const char * | filename, |
| bool | anew | ||
| ) |
Open a block-based file for writing.
| filename | The path of the file to open. |
| anew | If true, open the file anew (create or truncate it). |
Definition at line 125 of file io_utils.cc.
References move_to_higher_fd(), O_BINARY, O_CLOEXEC, and Xapian::InMemory::open().
Referenced by ChertTable::do_open_to_write(), GlassTable::do_open_to_write(), io_open_block_wr(), and test_ioblock1().
| 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 135 of file io_utils.cc.
Referenced by ChertTableCheck::check(), GlassChanges::check(), ChertDatabase::get_changeset_revisions(), GlassDatabase::get_changeset_revisions(), GlassVersion::read(), ChertTable_base::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 | ||
| ) |
Read block b size n bytes into buffer p from file descriptor fd, offset o.
Definition at line 192 of file io_utils.cc.
References rare, throw_block_error(), and usual.
Referenced by ChertTable::read_block(), GlassTable::read_block(), and test_ioblock1().
| 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 283 of file io_utils.cc.
References posixy_rename.
Referenced by ChertTable::commit(), GlassChanges::commit(), Xapian::Database::compact_(), 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(), GlassTable::create_and_open(), ChertTable::create_and_open(), ChertTable::erase(), 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 157 of file io_utils.cc.
Referenced by GlassChanges::commit(), ChertVersion::create(), 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().
| void io_write_block | ( | int | fd, |
| const char * | p, | ||
| size_t | n, | ||
| off_t | b, | ||
| off_t | o | ||
| ) |
Write block b size n bytes from buffer p to file descriptor fd, offset o.
Definition at line 240 of file io_utils.cc.
References rare, throw_block_error(), and usual.
Referenced by io_write_block(), ChertDatabaseReplicator::process_changeset_chunk_blocks(), GlassDatabaseReplicator::process_changeset_chunk_blocks(), test_ioblock1(), ChertTable::write_block(), and GlassTable::write_block().
|
inlinestatic |
Definition at line 118 of file io_utils.cc.
References MIN_WRITE_FD, move_to_higher_fd_(), and usual.
Referenced by io_open_block_wr().
|
static |
Definition at line 71 of file io_utils.cc.
References Assert, close(), and MIN_WRITE_FD.
Referenced by move_to_higher_fd().
|
static |
Definition at line 173 of file io_utils.cc.
References Xapian::Internal::str().
Referenced by io_read_block(), and io_write_block().
| const int MIN_WRITE_FD = 3 |
Definition at line 68 of file io_utils.cc.
Referenced by move_to_higher_fd(), and move_to_higher_fd_().