Gaudi Framework, version v25r2

Home   Generated: Wed Jun 4 2014
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
POSIXFileHandler Class Reference

#include <POSIXFileHandler.h>

Collaboration diagram for POSIXFileHandler:
Collaboration graph
[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.

:
m_log(msg,"POSIXFileHandler") {
m_level = msg->outputLevel("POSIXFileHandler");
}

Member Function Documentation

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

Definition at line 96 of file POSIXFileHandler.cpp.

{
m_log << MSG::DEBUG << "closePOSIXFile(fd:" << fd << ")"
<< endmsg;
if (fd == -1) {
m_log << MSG::ERROR << "Unable to close file: FD == -1 "
<< endmsg;
return -1;
}
if (close(fd) != 0) {
int ierr = errno;
m_log << MSG::ERROR << "Error closing POSIX file with FD " << fd
<< strerror(ierr)
<< endmsg;
return -1;
}
return 0;
}
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.

{
m_log << MSG::DEBUG << "openPOSIXFile(\"" << n << "\","
<< f << "," << desc << ")"
<< endmsg;
ptr = 0;
fd = -1;
int mm = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
fd = open(n.c_str(), (int) f, mm);
int ierr = errno;
if (fd == -1) {
m_log << MSG::ERROR << "Error opening POSIX file \"" << n << "\": "
<< strerror(ierr)
<< endmsg;
return 1;
}
std::string m;
if (f.isRead()) {
m = "r";
} else if ( f.isWrite() ) {
if ( (f & Io::APPEND) != 0) {
m = "a";
} else {
m = "w";
}
} else if ( f.isRdWr() ) {
m = "r+";
} else {
m_log << MSG::ERROR << "unknown mode " << f
<< " when calling fdopen on " << n
<< endmsg;
return 1;
}
if (m_log.level() <= MSG::DEBUG)
m_log << MSG::DEBUG << "calling fdopen with mode " << m << endmsg;
FILE* fp = fdopen(fd, m.c_str());
ierr = errno;
ptr = (void*) fp;
if (ptr == 0) {
m_log << MSG::ERROR << "Error calling fdopen on \"" << n << "\": "
<< strerror(ierr)
<< endmsg;
return 1;
}
m_log << MSG::DEBUG << "opened POSIX file, Fd: " << fd
<< " FILE*: " << ptr
<< endmsg;
return 0;
}
Io::reopen_t POSIXFileHandler::reopenPOSIXFile ( Io::Fd  fd,
const Io::IoFlags  
)

Definition at line 125 of file POSIXFileHandler.cpp.

{
m_log << MSG::ERROR << "reopen not implemented" << endmsg;
return -1;
}

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:
Generated at Wed Jun 4 2014 14:49:03 for Gaudi Framework, version v25r2 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004