From fef24cab1a4a13a864783dfcd6613ce8100f990d Mon Sep 17 00:00:00 2001 From: Ruben Dario Ponticeli Date: Mon, 13 Oct 2014 20:48:34 -0300 Subject: [PATCH] Add IsNull() to class CAutoFile and remove operator ! --- src/main.cpp | 8 ++++---- src/net.cpp | 4 ++-- src/serialize.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index f5fd7561c66..05f1a2eb4dd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1106,7 +1106,7 @@ bool WriteBlockToDisk(CBlock& block, CDiskBlockPos& pos) { // Open history file to append CAutoFile fileout(OpenBlockFile(pos), SER_DISK, CLIENT_VERSION); - if (!fileout) + if (fileout.IsNull()) return error("WriteBlockToDisk : OpenBlockFile failed"); // Write index header @@ -1134,7 +1134,7 @@ bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos) // Open history file to read CAutoFile filein(OpenBlockFile(pos, true), SER_DISK, CLIENT_VERSION); - if (!filein) + if (filein.IsNull()) return error("ReadBlockFromDisk : OpenBlockFile failed"); // Read block @@ -4548,7 +4548,7 @@ bool CBlockUndo::WriteToDisk(CDiskBlockPos &pos, const uint256 &hashBlock) { // Open history file to append CAutoFile fileout(OpenUndoFile(pos), SER_DISK, CLIENT_VERSION); - if (!fileout) + if (fileout.IsNull()) return error("CBlockUndo::WriteToDisk : OpenUndoFile failed"); // Write index header @@ -4580,7 +4580,7 @@ bool CBlockUndo::ReadFromDisk(const CDiskBlockPos &pos, const uint256 &hashBlock { // Open history file to read CAutoFile filein(OpenUndoFile(pos, true), SER_DISK, CLIENT_VERSION); - if (!filein) + if (filein.IsNull()) return error("CBlockUndo::ReadFromDisk : OpenBlockFile failed"); // Read block diff --git a/src/net.cpp b/src/net.cpp index 50b435cf14d..b7c958143cf 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1929,7 +1929,7 @@ bool CAddrDB::Write(const CAddrMan& addr) boost::filesystem::path pathTmp = GetDataDir() / tmpfn; FILE *file = fopen(pathTmp.string().c_str(), "wb"); CAutoFile fileout(file, SER_DISK, CLIENT_VERSION); - if (!fileout) + if (fileout.IsNull()) return error("%s : Failed to open file %s", __func__, pathTmp.string()); // Write and commit header, data @@ -1954,7 +1954,7 @@ bool CAddrDB::Read(CAddrMan& addr) // open input file, and associate with CAutoFile FILE *file = fopen(pathAddr.string().c_str(), "rb"); CAutoFile filein(file, SER_DISK, CLIENT_VERSION); - if (!filein) + if (filein.IsNull()) return error("%s : Failed to open file %s", __func__, pathAddr.string()); // use file size to size memory buffer diff --git a/src/serialize.h b/src/serialize.h index 55b6891394b..d8f0b76d594 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -1122,7 +1122,7 @@ public: FILE& operator*() { return *file; } FILE** operator&() { return &file; } FILE* operator=(FILE* pnew) { return file = pnew; } - bool operator!() { return (file == NULL); } + bool IsNull() const { return (file == NULL); } //