OpendTect  6.6
safefileio.h
Go to the documentation of this file.
1 #pragma once
2 
3 /*+
4 ________________________________________________________________________
5 
6  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
7  Author: A.H. Bril
8  Date: Nov 2004
9  RCS: $Id$
10 ________________________________________________________________________
11 
12 -*/
13 
14 #include "basicmod.h"
15 #include "od_iostream.h"
16 
17 
44 {
45 public:
46 
47  SafeFileIO(const char*,bool locked=false);
49 
50  bool open(bool forread,bool ignorelock=false);
51  const char* errMsg() const { return errmsg_.str(); }
54 
55  void closeFail( bool keeplock=false )
56  { doClose( keeplock, false ); }
57  bool closeSuccess( bool keeplock=false )
58  { return doClose( keeplock, true ); }
59 
60  const char* fileName() const { return filenm_.buf(); }
61 
62  // Some setup variables
66  double lockwaitincr_;
68 
72  bool remove();
73 
74 protected:
75 
76  const bool locked_;
83 
84  bool openRead(bool);
85  bool openWrite(bool);
86  bool commitWrite();
87  bool doClose(bool, bool);
88 
89  bool haveLock() const;
90  bool waitForLock() const;
91  void mkLock(bool);
92  void rmLock();
93 };
94 
95 
SafeFileIO::usebakwhenmissing_
bool usebakwhenmissing_
default=true
Definition: safefileio.h:63
SafeFileIO::errMsg
const char * errMsg() const
Definition: safefileio.h:51
SafeFileIO::closeFail
void closeFail(bool keeplock=false)
Definition: safefileio.h:55
SafeFileIO
Protects file IO when you can't afford to have partly written things after write errors or have a fil...
Definition: safefileio.h:44
SafeFileIO::errmsg_
BufferString errmsg_
Definition: safefileio.h:81
SafeFileIO::remove
bool remove()
mExpClass
#define mExpClass(module)
Definition: commondefs.h:177
SafeFileIO::lockwaitincr_
double lockwaitincr_
default=0.5 (seconds)
Definition: safefileio.h:66
od_istream
OD class for stream read common access to the std::cin.
Definition: od_istream.h:24
SafeFileIO::rmLock
void rmLock()
SafeFileIO::locked_
const bool locked_
Definition: safefileio.h:76
SafeFileIO::strm_
od_stream * strm_
Definition: safefileio.h:82
SafeFileIO::lockfnm_
const BufferString lockfnm_
Definition: safefileio.h:78
SafeFileIO::allowlockremove_
bool allowlockremove_
Definition: safefileio.h:67
SafeFileIO::open
bool open(bool forread, bool ignorelock=false)
SafeFileIO::mkLock
void mkLock(bool)
OD::String::str
const char * str() const
Definition: odstring.h:47
SafeFileIO::istrm
od_istream & istrm()
SafeFileIO::filenm_
const BufferString filenm_
Definition: safefileio.h:77
SafeFileIO::SafeFileIO
SafeFileIO(const char *, bool locked=false)
SafeFileIO::bakfnm_
const BufferString bakfnm_
Definition: safefileio.h:79
od_stream
OD base class for stream read/write.
Definition: od_stream.h:56
SafeFileIO::commitWrite
bool commitWrite()
SafeFileIO::haveLock
bool haveLock() const
BufferString
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size.
Definition: bufstring.h:40
od_iostream.h
SafeFileIO::waitForLock
bool waitForLock() const
SafeFileIO::openRead
bool openRead(bool)
SafeFileIO::openWrite
bool openWrite(bool)
SafeFileIO::doClose
bool doClose(bool, bool)
MPE::errmsg_
BufferString errmsg_
Definition: horizontracker.h:118
SafeFileIO::ostrm
od_ostream & ostrm()
SafeFileIO::fileName
const char * fileName() const
Definition: safefileio.h:60
SafeFileIO::closeSuccess
bool closeSuccess(bool keeplock=false)
Definition: safefileio.h:57
SafeFileIO::newfnm_
const BufferString newfnm_
Definition: safefileio.h:80
od_ostream
OD class for stream write common access to the user log file, or std::cout in other than od_main.
Definition: od_ostream.h:26
SafeFileIO::~SafeFileIO
~SafeFileIO()
SafeFileIO::lockretries_
int lockretries_
default=10
Definition: safefileio.h:65
SafeFileIO::removebakonsuccess_
bool removebakonsuccess_
default=false
Definition: safefileio.h:64

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B.V. 1995-2021