| The Gaudi Framework v29r0 (ff2e7097)

- 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 15 of file POSIXFileHandler.cpp.

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

## Member Function Documentation

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

Definition at line 78 of file POSIXFileHandler.cpp.

79 {
80
81 if ( m_log.level() <= MSG::DEBUG ) m_log << MSG::DEBUG << "closePOSIXFile(fd:" << fd << ")" << endmsg;
82
83 if ( fd == -1 ) {
84 m_log << MSG::ERROR << "Unable to close file: FD == -1 " << endmsg;
85 return -1;
86 }
87
88 if ( close( fd ) != 0 ) {
89 int ierr = errno;
90 m_log << MSG::ERROR << "Error closing POSIX file with FD " << fd << strerror( ierr ) << endmsg;
91 return -1;
92 }
93
94 return 0;
95 }
gaudirun.fd
fd
Definition: gaudirun.py:478
std::strerror
T strerror(T...args)
MSG::DEBUG
Definition: IMessageSvc.h:16
POSIXFileHandler::m_log
MsgStream m_log
Definition: POSIXFileHandler.h:30
MSG::ERROR
Definition: IMessageSvc.h:16
MsgStream::level
MSG::Level level() const
Retrieve output level.
Definition: MsgStream.h:108
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209

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 23 of file POSIXFileHandler.cpp.

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

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

Definition at line 99 of file POSIXFileHandler.cpp.

100 {
101
102 m_log << MSG::ERROR << "reopen not implemented" << endmsg;
103 return -1;
104 }
POSIXFileHandler::m_log
MsgStream m_log
Definition: POSIXFileHandler.h:30
MSG::ERROR
Definition: IMessageSvc.h:16
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209

## Member Data Documentation

int POSIXFileHandler::m_level
| private

Definition at line 31 of file POSIXFileHandler.h.

MsgStream POSIXFileHandler::m_log
| private

Definition at line 30 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