Disk ARchive
2.4.10
Main Page
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
src
libdar
tuyau.hpp
Go to the documentation of this file.
1
/*********************************************************************/
2
// dar - disk archive - a backup/restoration program
3
// Copyright (C) 2002-2052 Denis Corbin
4
//
5
// This program is free software; you can redistribute it and/or
6
// modify it under the terms of the GNU General Public License
7
// as published by the Free Software Foundation; either version 2
8
// of the License, or (at your option) any later version.
9
//
10
// This program is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
// GNU General Public License for more details.
14
//
15
// You should have received a copy of the GNU General Public License
16
// along with this program; if not, write to the Free Software
17
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
//
19
// to contact the author : http://dar.linux.free.fr/email.html
20
/*********************************************************************/
21
30
31
#ifndef TUYAU_HPP
32
#define TUYAU_HPP
33
34
#include "../my_config.h"
35
#include "
infinint.hpp
"
36
#include "
generic_file.hpp
"
37
#include "
thread_cancellation.hpp
"
38
39
namespace
libdar
40
{
41
43
45
46
class
tuyau
:
public
generic_file
,
public
thread_cancellation
,
protected
mem_ui
47
{
48
public
:
49
tuyau
(
user_interaction
& dialog,
//< for user interaction
50
int
fd);
//< fd is the filedescriptor of a pipe extremity already openned
51
tuyau
(
user_interaction
& dialog,
52
int
fd,
//< fd is the filedescriptor of a pipe extremity already openned
53
gf_mode
mode);
//< forces the mode if possible
54
tuyau
(
user_interaction
& dialog,
//< for user interaction
55
const
std::string &filename,
//< named pipe to open
56
gf_mode
mode);
//< forces the mode if possible
57
tuyau
(
user_interaction
& dialog);
//< creates a anonymous pipe and bind itself to the writing end. The reading end can be obtained by get_read_side() method
58
~
tuyau
();
59
60
// provides the reading end of the anonymous pipe when the current object has created it (no filedesc, no path given to constructor).
61
// it cannot be called more than once.
62
int
get_read_fd()
const
;
63
65
69
void
close_read_fd
();
70
72
void
do_not_close_read_fd
();
73
74
// inherited from generic_file
75
bool
skip
(
const
infinint
& pos);
76
bool
skip_to_eof
();
77
bool
skip_relative(
signed
int
x);
78
infinint
get_position
() {
return
position; };
79
80
bool
has_next_to_read();
81
82
protected
:
83
virtual
U_I
inherited_read
(
char
*a, U_I size);
84
virtual
void
inherited_write
(
const
char
*a, U_I size);
85
void
inherited_sync_write
() {};
86
void
inherited_terminate
();
87
88
private
:
89
enum
90
{
91
pipe_fd,
//< holds a single file descriptor for the pipe
92
pipe_path,
//< holds a filename to be openned (named pipe)
93
pipe_both
//< holds a pair of file descriptors
94
}
95
pipe_mode;
//< defines how the object's status (which possible values defined by the anonymous enum above)
96
infinint position;
//< recorded position in the stream
97
int
filedesc;
//< file descriptors of the pipe
98
int
other_end_fd;
//< in pipe_both mode, this holds the reading side of the anonymous pipe
99
std::string chemin;
//< in pipe_path mode only, this holds the named pipe to be open
100
bool
has_one_to_read;
//< if true, the next char to read is placed in "next_to_read"
101
char
next_to_read;
//< when has_one_to_read is true, contains the next to read byte
102
103
void
ouverture();
104
106
109
bool
read_and_drop(infinint byte);
110
112
bool
read_to_eof();
113
};
114
115
}
// end of namespace
116
117
#endif
Generated on Mon Mar 11 2013 22:09:59 for Disk ARchive by
1.8.2