xapian-core  1.4.26
Functions
databasehelpers.h File Reference

Helper functions for database handling. More...

#include <cerrno>
#include <cstdlib>
#include <fstream>
#include <string>
#include "fileutils.h"
#include "safesysstat.h"
#include "safeunistd.h"
#include "str.h"
#include "xapian/error.h"
+ Include dependency graph for databasehelpers.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int test_if_single_file_db (const struct stat &sb, const std::string &path, int *fd_ptr)
 Probe if a path is a single-file database. More...
 
template<typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 >
void read_stub_file (const std::string &file, A1 action_auto, A2 action_chert, A3 action_glass, A4 action_remote_prog, A5 action_remote_tcp, A6 action_inmemory)
 Open, read and process a stub database file. More...
 

Detailed Description

Helper functions for database handling.

Definition in file databasehelpers.h.

Function Documentation

◆ read_stub_file()

template<typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 >
void read_stub_file ( const std::string &  file,
A1  action_auto,
A2  action_chert,
A3  action_glass,
A4  action_remote_prog,
A5  action_remote_tcp,
A6  action_inmemory 
)

Open, read and process a stub database file.

Implemented as a template with separate actions for each database type.

Definition at line 64 of file databasehelpers.h.

References resolve_relative_path(), and Xapian::Internal::str().

Referenced by Xapian::check_stub(), and Xapian::open_stub().

◆ test_if_single_file_db()

int test_if_single_file_db ( const struct stat &  sb,
const std::string &  path,
int *  fd_ptr 
)

Probe if a path is a single-file database.

Parameters
sbstruct statbuf from calling stat() on path
pathpath to probe
fd_ptrused to return fd open of path (unless BACKEND_UNKNOWN is returned)
Returns
A BACKEND_* constant from backends.h:
  • BACKEND_UNKNOWN : unknown (could be a stub file)
  • BACKEND_GLASS : glass single file

Definition at line 45 of file databasehelpers.cc.

References Assert, BACKEND_GLASS, BACKEND_UNKNOWN, close(), GLASS_MIN_BLOCKSIZE, io_read(), O_BINARY, posixy_open, and S_ISREG.

Referenced by Xapian::Database::check_(), and Xapian::Database::Database().