LCOV - code coverage report
Current view: top level - cppprocess/cppprocess - io_file.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 1 100.0 %
Date: 2022-06-18 10:10:36 Functions: 1 2 50.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // Copyright (c) 2013-2022  Made to Order Software Corp.  All Rights Reserved
       2             : //
       3             : // https://snapwebsites.org/project/eventdispatcher
       4             : // contact@m2osw.com
       5             : //
       6             : // This program is free software; you can redistribute it and/or modify
       7             : // it under the terms of the GNU General Public License as published by
       8             : // the Free Software Foundation; either version 2 of the License, or
       9             : // (at your option) any later version.
      10             : //
      11             : // This program is distributed in the hope that it will be useful,
      12             : // but WITHOUT ANY WARRANTY; without even the implied warranty of
      13             : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14             : // GNU General Public License for more details.
      15             : //
      16             : // You should have received a copy of the GNU General Public License along
      17             : // with this program; if not, write to the Free Software Foundation, Inc.,
      18             : // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      19             : #pragma once
      20             : 
      21             : // self
      22             : //
      23             : #include    <cppprocess/io.h>
      24             : 
      25             : 
      26             : // snapdev lib
      27             : //
      28             : #include    <snapdev/raii_generic_deleter.h>
      29             : 
      30             : 
      31             : // C lib
      32             : //
      33             : #include    <fcntl.h>
      34             : 
      35             : 
      36             : 
      37             : namespace cppprocess
      38             : {
      39             : 
      40             : 
      41             : 
      42           2 : class io_file
      43             :     : public io
      44             : {
      45             : public:
      46             :                             io_file(io_flags_t flags);
      47             : 
      48             :     void                    set_filename(std::string const & filename);
      49             :     std::string const &     get_filename() const;
      50             : 
      51             :     void                    set_truncate(bool truncate);
      52             :     bool                    get_truncate() const;
      53             :     void                    set_append(bool append);
      54             :     bool                    get_append() const;
      55             : 
      56             :     void                    set_mode(int mode);
      57             :     int                     get_mode() const;
      58             : 
      59             :     // io implementation
      60             :     //
      61             :     virtual int             get_fd() override;
      62             :     virtual int             get_other_fd() override;
      63             :     virtual void            close_both() override;
      64             :     virtual void            close_other() override;
      65             :     virtual void            process_starting() override;
      66             : 
      67             : private:
      68             :     std::string             f_filename = std::string();
      69             :     bool                    f_truncate = false;
      70             :     bool                    f_append = false;
      71             :     int                     f_mode = S_IRUSR | S_IWUSR;
      72             :     snapdev::raii_fd_t      f_file = snapdev::raii_fd_t();
      73             : };
      74             : 
      75             : 
      76             : 
      77             : } // namespace cppprocess
      78             : // vim: ts=4 sw=4 et

Generated by: LCOV version 1.13