| # Gaudi Framework, version v21r11 |

Home |  | Generated: 30 Sep 2010

# FileReadTool.cpp

Go to the documentation of this file.

    00001 #include "FileReadTool.h"
    00002 #include <fstream>
    00003
    00004 #include "GaudiKernel/ToolFactory.h"
    00005 DECLARE_TOOL_FACTORY( FileReadTool )
    00006
    00007 FileReadTool::FileReadTool( const std::string& type,
    00008                             const std::string& name,
    00009                             const IInterface* parent):
    00010   base_class(type, name, parent)
    00011 {
    00012   //declareInterface<IFileAccess>(this);
    00013   m_protocols.push_back("file");
    00014 }
    00015
    00016 FileReadTool::~FileReadTool(){}
    00017
    00018 std::auto_ptr<std::istream> FileReadTool::open(const std::string &url) {
    00019   // remove the optional "file://" from the beginning of the url
    00020   std::string path;
    00021   if ( url.substr(0,7) == "file://" ) {
    00022     path = url.substr(7);
    00023   } else {
    00024     path = url;
    00025   }
    00026   return std::auto_ptr<std::istream>(new std::ifstream(path.c_str()));
    00027 }
    00028
    00029 const std::vector<std::string> &FileReadTool::protocols() const
    00030 {
    00031   return m_protocols;
    00032 }