| The Gaudi Framework v32r1 (f65d50dc)

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::POSIXFileHandler | ( | IMessageSvc * | msg | ) |

Definition at line 15 of file POSIXFileHandler.cpp.

15 : m_log( msg, "POSIXFileHandler" ) {
16
17 m_level = msg->outputLevel( "POSIXFileHandler" );
18 }
POSIXFileHandler::m_level
int m_level
Definition: POSIXFileHandler.h:30
POSIXFileHandler::m_log
MsgStream m_log
Definition: POSIXFileHandler.h:29
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:8

## Member Function Documentation

## ◆ closePOSIXFile()

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

Definition at line 76 of file POSIXFileHandler.cpp.

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

## ◆ openPOSIXFile()

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

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

## ◆ reopenPOSIXFile()

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

Definition at line 96 of file POSIXFileHandler.cpp.

96 {
97
98 m_log << MSG::ERROR << "reopen not implemented" << endmsg;
99 return -1;
100 }
POSIXFileHandler::m_log
MsgStream m_log
Definition: POSIXFileHandler.h:29
MSG::ERROR
Definition: IMessageSvc.h:15
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192

## Member Data Documentation

## ◆ m_level

int POSIXFileHandler::m_level
| private

Definition at line 30 of file POSIXFileHandler.h.

## ◆ m_log

MsgStream POSIXFileHandler::m_log
| private

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