Monarch  v3.8.2
Project 8 Data File Format Library
M2IO.cc
Go to the documentation of this file.
1 #include "M2IO.hh"
2 
3 namespace monarch2
4 {
5 
7  fFile( NULL ),
8  fMode( aMode )
9  {
10 
11  }
13  {
14  if( fFile )
15  {
16  fclose( fFile );
17  }
18  }
19 
20  bool M2IO::Open( const std::string& aFilename )
21  {
22  if( fMode == sAccessRead )
23  {
24  fFile = fopen( aFilename.c_str(), "rb" );
25  }
26  else if( fMode == sAccessWrite )
27  {
28  fFile = fopen( aFilename.c_str(), "wb" );
29  }
30 
31  if( fFile == NULL )
32  {
33  return false;
34  }
35  return true;
36  }
37  bool M2IO::Done()
38  {
39  if( fFile != NULL )
40  {
41  if( feof( fFile ) == 0 )
42  {
43  return false;
44  }
45  return true;
46  }
47  return false;
48  }
49  bool M2IO::Close()
50  {
51  if( fFile )
52  {
53  if( fclose( fFile ) != 0 )
54  {
55  fFile = NULL;
56  return false;
57  }
58  fFile = NULL;
59  return true;
60  }
61  return false;
62  }
63 
64 }
static const AccessModeType sAccessRead
Definition: M2Types.hh:31
bool Close()
Definition: M2IO.cc:49
AccessModeType fMode
Definition: M2IO.hh:18
FILE * fFile
Definition: M2IO.hh:17
uint32_t AccessModeType
Definition: M2Types.hh:30
static const AccessModeType sAccessWrite
Definition: M2Types.hh:32
bool Open(const std::string &aFilename)
Definition: M2IO.cc:20
bool Done()
Definition: M2IO.cc:37
M2IO(AccessModeType aMode)
Definition: M2IO.cc:6