|
xapian-core
2.0.0
|
Wrappers for low-level POSIX I/O routines. More...
Include dependency graph for io_utils.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Functions | |
| int | io_open_block_rd (const char *filename) |
| Open a block-based file for reading. More... | |
| int | io_open_block_rd (const std::string &filename) |
| Open a block-based file for reading. More... | |
| int | io_open_block_wr (const char *filename, bool anew) |
| Open a block-based file for writing. More... | |
| int | io_open_block_wr (const std::string &filename, bool anew) |
| Open a block-based file for writing. More... | |
| int | io_open_stream_rd (const char *filename) |
| Open a stream-based file for reading. More... | |
| int | io_open_stream_rd (const std::string &filename) |
| Open a stream-based file for reading. More... | |
| int | io_open_stream_wr (const char *filename, bool anew) |
| Open a stream-based file for writing. More... | |
| int | io_open_stream_wr (const std::string &filename, bool anew) |
| Open a stream-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) |
| size_t | io_pread (int fd, char *p, size_t n, off_t o, size_t min=0) |
| Read n bytes (or until EOF) into block pointed to by p from file descriptor fd starting at position o. More... | |
| void | io_pwrite (int fd, const char *p, size_t n, off_t o) |
| Write n bytes from block pointed to by p to file descriptor fd starting at position o. More... | |
| 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 122 of file io_utils.h.
References io_sync().
Referenced by GlassVersion::sync(), HoneyVersion::sync(), and test_ioblock1().
|
inline |
Open a block-based file for reading.
| filename | The path of the file to open. |
Definition at line 38 of file io_utils.h.
References O_BINARY, O_CLOEXEC, and Xapian::Remote::open().
Referenced by GlassTable::do_open_to_read(), io_open_block_rd(), and test_ioblock1().
|
inline |
Open a block-based file for reading.
| filename | The path of the file to open. |
Definition at line 46 of file io_utils.h.
References io_open_block_rd().
| 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 192 of file io_utils.cc.
References move_to_higher_fd(), O_BINARY, O_CLOEXEC, Xapian::Remote::open(), and protect_from_write().
Referenced by GlassTable::do_open_to_write(), io_open_block_wr(), and test_ioblock1().
|
inline |
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 63 of file io_utils.h.
References io_open_block_wr().
|
inline |
Open a stream-based file for reading.
| filename | The path of the file to open. |
Definition at line 72 of file io_utils.h.
References O_BINARY, O_CLOEXEC, and Xapian::Remote::open().
Referenced by io_open_stream_rd(), and BufferedFile::open().
|
inline |
Open a stream-based file for reading.
| filename | The path of the file to open. |
Definition at line 80 of file io_utils.h.
References io_open_stream_rd().
| int io_open_stream_wr | ( | const char * | filename, |
| bool | anew | ||
| ) |
Open a stream-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 231 of file io_utils.cc.
References move_to_higher_fd(), O_BINARY, O_CLOEXEC, and Xapian::Remote::open().
Referenced by io_open_stream_wr(), and BufferedFile::open().
|
inline |
Open a stream-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 97 of file io_utils.h.
References io_open_stream_wr().
| size_t io_pread | ( | int | fd, |
| char * | p, | ||
| size_t | n, | ||
| off_t | o, | ||
| size_t | min = 0 |
||
| ) |
Read n bytes (or until EOF) into block pointed to by p from file descriptor fd starting at position o.
If a read error occurs, throws DatabaseError.
If min is specified and EOF is reached after less than min bytes, throws DatabaseCorruptError.
The current file position may or may not be updated.
Returns the number of bytes actually read.
Definition at line 277 of file io_utils.cc.
References p, rare, and usual.
Referenced by BufferedFile::read().
| void io_pwrite | ( | int | fd, |
| const char * | p, | ||
| size_t | n, | ||
| off_t | o | ||
| ) |
Write n bytes from block pointed to by p to file descriptor fd starting at position o.
If a read error occurs, throws DatabaseError.
The current file position may or may not be updated.
Definition at line 363 of file io_utils.cc.
References io_write(), p, rare, and usual.
| 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 241 of file io_utils.cc.
References p.
Referenced by GlassChanges::check(), GlassDatabase::get_changeset_revisions(), GlassVersion::read(), HoneyVersion::read(), 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 432 of file io_utils.cc.
References p, rare, throw_block_error(), and usual.
Referenced by 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 190 of file io_utils.h.
Referenced by GlassTable::readahead_key(), and test_ioblock1().
|
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 107 of file io_utils.h.
Referenced by GlassDatabaseReplicator::commit(), GlassChanges::commit(), io_full_sync(), GlassDatabaseReplicator::process_changeset_chunk_version(), GlassTable::sync(), BufferedFile::sync(), GlassVersion::sync(), HoneyVersion::sync(), 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 573 of file io_utils.cc.
References posixy_rename.
Referenced by GlassChanges::commit(), Xapian::Database::compact_(), GlassDatabaseReplicator::process_changeset_chunk_version(), GlassVersion::sync(), HoneyVersion::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 56 of file io_utils.cc.
References posixy_unlink.
Referenced by GlassChanges::commit(), GlassTable::create_and_open(), test_ioblock1(), 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 263 of file io_utils.cc.
References p.
Referenced by GlassChanges::commit(), BufferedFile::flush(), io_pwrite(), io_write(), GlassDatabaseReplicator::process_changeset_chunk_version(), GlassChanges::start(), GlassVersion::write(), HoneyVersion::write(), BufferedFile::write(), write_and_clear_changes(), and GlassChanges::write_block().
|
inline |
Definition at line 156 of file io_utils.h.
References io_write(), and p.
| 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 507 of file io_utils.cc.
References p, rare, throw_block_error(), and usual.
Referenced by io_write_block(), GlassDatabaseReplicator::process_changeset_chunk_blocks(), test_ioblock1(), and GlassTable::write_block().
|
inline |
Definition at line 199 of file io_utils.h.
References io_write_block(), and p.