| The Gaudi Framework v27r1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Private Attributes | List of all members
POSIXFileHandler Class Reference

`#include <src/FileMgr/POSIXFileHandler.h>`

Collaboration diagram for POSIXFileHandler:
[legend]

## Public Member Functions
| POSIXFileHandler (IMessageSvc *)
Io::open_t | openPOSIXFile (const std::string &n, const Io::IoFlags &f, const std::string &desc, Io::Fd &fd, void *&ptr)
Io::close_t | closePOSIXFile (Io::Fd fd)
Io::reopen_t | reopenPOSIXFile (Io::Fd fd, const Io::IoFlags &)

## Private Attributes
MsgStream | m_log
int | m_level

## Detailed Description

Definition at line 17 of file POSIXFileHandler.h.

## Constructor & Destructor Documentation

POSIXFileHandler::POSIXFileHandler | ( | IMessageSvc * | msg | ) |

Definition at line 16 of file POSIXFileHandler.cpp.

16 :
17 m_log(msg,"POSIXFileHandler") {
18
19 m_level = msg->outputLevel("POSIXFileHandler");
20
21 }
POSIXFileHandler::m_level
int m_level
Definition: POSIXFileHandler.h:32
IMessageSvc::outputLevel
virtual int outputLevel() const =0
Retrieve the current output level threshold.
POSIXFileHandler::m_log
MsgStream m_log
Definition: POSIXFileHandler.h:31

## Member Function Documentation

Io::close_t POSIXFileHandler::closePOSIXFile | ( | Io::Fd | fd | ) |

Definition at line 95 of file POSIXFileHandler.cpp.

95 {
96
97 if (m_log.level() <= MSG::DEBUG)
98 m_log << MSG::DEBUG << "closePOSIXFile(fd:" << fd << ")"
99 << endmsg;
100
101
102 if (fd == -1) {
103 m_log << MSG::ERROR << "Unable to close file: FD == -1 "
104 << endmsg;
105 return -1;
106 }
107
108 if (close(fd) != 0) {
109 int ierr = errno;
110 m_log << MSG::ERROR << "Error closing POSIX file with FD " << fd
111 << strerror(ierr)
112 << endmsg;
113 return -1;
114 }
115
116 return 0;
117
118 }
MsgStream::level
MSG::Level level()
Retrieve output level.
Definition: MsgStream.h:112
std::strerror
T strerror(T...args)
MSG::DEBUG
Definition: IMessageSvc.h:18
POSIXFileHandler::m_log
MsgStream m_log
Definition: POSIXFileHandler.h:31
MSG::ERROR
Definition: IMessageSvc.h:21
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

Io::open_t POSIXFileHandler::openPOSIXFile | ( | const std::string & | n,
|  | const Io::IoFlags & | f,
|  | const std::string & | desc,
|  | Io::Fd & | fd,
|  | void *& | ptr
| ) |  |

Definition at line 27 of file POSIXFileHandler.cpp.

28 {
29
30 m_log.setLevel(m_level);
31
32 if (m_log.level() <= MSG::DEBUG)
33 m_log << MSG::DEBUG << "openPOSIXFile(\"" << n << "\","
34 << f << "," << desc << ")"
35 << endmsg;
36
37 ptr = nullptr;
38 fd = -1;
39
40 int mm = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
41
42 fd = open(n.c_str(), (int) f, mm);
43 int ierr = errno;
44
45 if (fd == -1) {
46 m_log << MSG::ERROR << "Error opening POSIX file \"" << n << "\": "
47 << strerror(ierr)
48 << endmsg;
49 return 1;
50 }
51
52 std::string m;
53 if (f.isRead()) {
54 m = "r";
55 } else if ( f.isWrite() ) {
56 if ( (f & Io::APPEND) ) {
57 m = "a";
58 } else {
59 m = "w";
60 }
61 } else if ( f.isRdWr() ) {
62 m = "r+";
63 } else {
64 m_log << MSG::ERROR << "unknown mode " << f
65 << " when calling fdopen on " << n
66 << endmsg;
67 return 1;
68 }
69
70
71 if (m_log.level() <= MSG::DEBUG)
72 m_log << MSG::DEBUG << "calling fdopen with mode " << m << endmsg;
73
74 ptr = fdopen(fd, m.c_str());
75 ierr = errno;
76
77 if (!ptr) {
78 m_log << MSG::ERROR << "Error calling fdopen on \"" << n << "\": "
79 << strerror(ierr)
80 << endmsg;
81 return 1;
82 }
83
84 m_log << MSG::DEBUG << "opened POSIX file, Fd: " << fd
85 << " FILE*: " << ptr
86 << endmsg;
87
88 return 0;
89
90 }
MsgStream::level
MSG::Level level()
Retrieve output level.
Definition: MsgStream.h:112
std::strerror
T strerror(T...args)
MSG::DEBUG
Definition: IMessageSvc.h:18
Gaudi::Units::mm
constexpr double mm
Definition: SystemOfUnits.h:85
std::string
STL class.
POSIXFileHandler::m_level
int m_level
Definition: POSIXFileHandler.h:32
POSIXFileHandler::m_log
MsgStream m_log
Definition: POSIXFileHandler.h:31
Gaudi::Units::m
constexpr double m
Definition: SystemOfUnits.h:93
Io::IoFlags::isWrite
bool isWrite() const
Definition: IFileMgr.h:55
Io::APPEND
Definition: IFileMgr.h:34
std::string::c_str
T c_str(T...args)
MsgStream::setLevel
void setLevel(int level)
Update outputlevel.
Definition: MsgStream.h:106
Io::IoFlags::isRead
bool isRead() const
Definition: IFileMgr.h:54
MSG::ERROR
Definition: IMessageSvc.h:21
Io::IoFlags::isRdWr
bool isRdWr() const
Definition: IFileMgr.h:56
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

Io::reopen_t POSIXFileHandler::reopenPOSIXFile | ( | Io::Fd | fd,
|  | const Io::IoFlags & |
| ) |  |

Definition at line 124 of file POSIXFileHandler.cpp.

124 {
125
126 m_log << MSG::ERROR << "reopen not implemented" << endmsg;
127 return -1;
128
129 }
POSIXFileHandler::m_log
MsgStream m_log
Definition: POSIXFileHandler.h:31
MSG::ERROR
Definition: IMessageSvc.h:21
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

## Member Data Documentation

int POSIXFileHandler::m_level
| private

Definition at line 32 of file POSIXFileHandler.h.

MsgStream POSIXFileHandler::m_log
| private

Definition at line 31 of file POSIXFileHandler.h.

The documentation for this class was generated from the following files:

- GaudiSvc/src/FileMgr/POSIXFileHandler.h
- GaudiSvc/src/FileMgr/POSIXFileHandler.cpp