LTP GCOV extension - code coverage report
Current view: directory - src/cpp/prod/protocol/cdr - cdr_file.cpp
Test: YAORB-0.2.info
Date: 2006-02-27 Instrumented lines: 21
Code covered: 85.7 % Executed lines: 18

       1                 : //==============================================================================
       2                 : // File <$/src/cpp/prod/protocol/cdr/cdr_file.cpp>
       3                 : // This file is part of YaOrb : Yet Another Object Request Broker,
       4                 : // Copyright (c) 2000-2003, 2006, Marc Alff.
       5                 : //
       6                 : // This program is free software; you can redistribute it and/or
       7                 : // modify it under the terms of the GNU General Public License
       8                 : // as published by the Free Software Foundation; either version 2
       9                 : // of the License, or (at your option) any later version.
      10                 : //
      11                 : // This program is distributed in the hope that it will be useful,
      12                 : // but WITHOUT ANY WARRANTY; without even the implied warranty of
      13                 : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14                 : // GNU General Public License for more details.
      15                 : //
      16                 : // You should have received a copy of the GNU General Public License
      17                 : // along with this program; if not, write to the Free Software
      18                 : // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
      19                 : //
      20                 : //==============================================================================
      21                 : 
      22                 : #include "src/cpp/prod/tool/DEVELOPMENT.h"
      23                 : #include "src/cpp/prod/tool/Assert.h"
      24                 : 
      25                 : #include "src/cpp/prod/protocol/cdr/cdr_file.h"
      26                 : #include "src/cpp/prod/protocol/cdr/msg.h"
      27                 : 
      28              72 : CDRFile::CDRFile(const char *fileName, YAORB::CDR_Op op)
      29              72 :  : YAORB::CDR(op), _file(NULL)
      30                 : {
      31              72 :    const char* mode = (op == YAORB::CDR_READ ? "r" : "w") ;
      32                 : 
      33              72 :    _file = fopen(fileName, mode) ;
      34              72 :    if (_file == NULL)
      35                 :    {
      36               0 :       ThrowMarshal(this) ;
      37                 :    }
      38               0 : }
      39                 : 
      40              72 : CDRFile::~CDRFile()
      41                 : {
      42              72 :    if (_file)
      43                 :    {
      44              72 :       fclose(_file) ;
      45                 :    }
      46               0 : }
      47                 : 
      48                 : void CDRFile::GetBytes(CORBA::Octet *buffer, int size)
      49             303 : throw (CORBA::SystemException)
      50                 : {
      51                 :    int rc ;
      52                 : 
      53             303 :    rc = fread(buffer, 1, size, _file) ;
      54                 : 
      55             303 :    if (rc != size) ThrowMarshal(this) ;
      56                 : 
      57             303 :    _position += size ;
      58             303 : }
      59                 : 
      60                 : void CDRFile::PutBytes(CORBA::Octet *buffer, int size)
      61             101 : throw (CORBA::SystemException)
      62                 : {
      63                 :    int rc ;
      64                 : 
      65             101 :    rc = fwrite(buffer, 1, size, _file) ;
      66                 : 
      67             101 :    if (rc != size) ThrowMarshal(this) ;
      68                 : 
      69             101 :    _position += size ;
      70             101 : }
      71                 : 

Generated by: LTP GCOV extension version 1.4