LCOV - code coverage report
Current view: top level - common - replicate_utils.cc (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core 954b5873a738 Lines: 0 15 0.0 %
Date: 2019-06-30 05:20:33 Functions: 0 2 0.0 %
Branches: 0 10 0.0 %

           Branch data     Line data    Source code
       1                 :            : /** @file replicate_utils.cc
       2                 :            :  * @brief Utility functions for replication implementations
       3                 :            :  */
       4                 :            : /* Copyright (C) 2010 Richard Boulton
       5                 :            :  * Copyright (C) 2010 Olly Betts
       6                 :            :  *
       7                 :            :  * This program is free software; you can redistribute it and/or modify
       8                 :            :  * it under the terms of the GNU General Public License as published by
       9                 :            :  * the Free Software Foundation; either version 2 of the License, or
      10                 :            :  * (at your option) any later version.
      11                 :            :  *
      12                 :            :  * This program is distributed in the hope that it will be useful,
      13                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      14                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      15                 :            :  * GNU General Public License for more details.
      16                 :            :  *
      17                 :            :  * You should have received a copy of the GNU General Public License
      18                 :            :  * along with this program; if not, write to the Free Software
      19                 :            :  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
      20                 :            :  */
      21                 :            : 
      22                 :            : #include <config.h>
      23                 :            : 
      24                 :            : #include "replicate_utils.h"
      25                 :            : 
      26                 :            : #include "xapian/error.h"
      27                 :            : 
      28                 :            : #include "io_utils.h"
      29                 :            : #include "posixy_wrapper.h"
      30                 :            : 
      31                 :            : #include "safefcntl.h"
      32                 :            : #include "safesysstat.h"
      33                 :            : #include "safeunistd.h"
      34                 :            : 
      35                 :            : #include <sys/types.h>
      36                 :            : 
      37                 :            : #include <cerrno>
      38                 :            : #include <string>
      39                 :            : 
      40                 :            : using namespace std;
      41                 :            : 
      42                 :            : int
      43                 :          0 : create_changeset_file(const string & changeset_dir,
      44                 :            :                       const string & filename,
      45                 :            :                       string & changes_name)
      46                 :            : {
      47                 :          0 :     changes_name = changeset_dir;
      48                 :          0 :     changes_name += '/';
      49                 :          0 :     changes_name += filename;
      50                 :          0 :     int changes_fd = posixy_open(changes_name.c_str(), O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0666);
      51         [ #  # ]:          0 :     if (changes_fd < 0) {
      52         [ #  # ]:          0 :         string message("Couldn't open changeset to write: ");
      53         [ #  # ]:          0 :         message += changes_name;
      54         [ #  # ]:          0 :         throw Xapian::DatabaseError(message, errno);
      55                 :            :     }
      56                 :          0 :     return changes_fd;
      57                 :            : }
      58                 :            : 
      59                 :            : void
      60                 :          0 : write_and_clear_changes(int changes_fd, string & buf, size_t bytes)
      61                 :            : {
      62         [ #  # ]:          0 :     if (changes_fd != -1) {
      63                 :          0 :         io_write(changes_fd, buf.data(), bytes);
      64                 :            :     }
      65                 :          0 :     buf.erase(0, bytes);
      66                 :          0 : }

Generated by: LCOV version 1.11