diff options
author | Chris Wilson <chris+github@qwirx.com> | 2014-10-31 22:09:34 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2014-10-31 22:09:34 +0000 |
commit | 6d52b312e556356030edd6ec5904faa63f5b9778 (patch) | |
tree | a51f6cd249f0c9b1e09a744c61d3e6b4a2afc210 /lib/backupstore/BackupStoreDirectory.cpp | |
parent | d95ae43d507af4f02749f1dd99500f3220253002 (diff) |
Whitespace, comment and readability fixes
Diffstat (limited to 'lib/backupstore/BackupStoreDirectory.cpp')
-rw-r--r-- | lib/backupstore/BackupStoreDirectory.cpp | 120 |
1 files changed, 61 insertions, 59 deletions
diff --git a/lib/backupstore/BackupStoreDirectory.cpp b/lib/backupstore/BackupStoreDirectory.cpp index edef25bc..37957770 100644 --- a/lib/backupstore/BackupStoreDirectory.cpp +++ b/lib/backupstore/BackupStoreDirectory.cpp @@ -139,21 +139,21 @@ void BackupStoreDirectory::ReadFromStream(IOStream &rStream, int Timeout) BOX_FORMAT_HEX32(ntohl(hdr.mMagicValue)) << " in " << rStream.ToString()); } - + // Get data mObjectID = box_ntoh64(hdr.mObjectID); mContainerID = box_ntoh64(hdr.mContainerID); mAttributesModTime = box_ntoh64(hdr.mAttributesModTime); - + // Options int32_t options = ntohl(hdr.mOptionsPresent); - + // Get attributes mAttributes.ReadFromStream(rStream, Timeout); - + // Decode count int count = ntohl(hdr.mNumEntries); - + // Clear existing list for(std::vector<Entry*>::iterator i = mEntries.begin(); i != mEntries.end(); i++) @@ -161,7 +161,7 @@ void BackupStoreDirectory::ReadFromStream(IOStream &rStream, int Timeout) delete (*i); } mEntries.clear(); - + // Read them in! for(int c = 0; c < count; ++c) { @@ -170,7 +170,7 @@ void BackupStoreDirectory::ReadFromStream(IOStream &rStream, int Timeout) { // Read from stream pen->ReadFromStream(rStream, Timeout); - + // Add to list mEntries.push_back(pen); } @@ -180,7 +180,7 @@ void BackupStoreDirectory::ReadFromStream(IOStream &rStream, int Timeout) throw; } } - + // Read in dependency info? if(options & Option_DependencyInfoPresent) { @@ -214,11 +214,11 @@ void BackupStoreDirectory::WriteToStream(IOStream &rStream, int16_t FlagsMustBeS count++; } } - + // Check that sensible IDs have been set ASSERT(mObjectID != 0); ASSERT(mContainerID != 0); - + // Need dependency info? bool dependencyInfoRequired = false; if(StreamDependencyInfo) @@ -231,9 +231,9 @@ void BackupStoreDirectory::WriteToStream(IOStream &rStream, int16_t FlagsMustBeS { dependencyInfoRequired = true; } - } + } } - + // Options int32_t options = 0; if(dependencyInfoRequired) options |= Option_DependencyInfoPresent; @@ -246,10 +246,10 @@ void BackupStoreDirectory::WriteToStream(IOStream &rStream, int16_t FlagsMustBeS hdr.mContainerID = box_hton64(mContainerID); hdr.mAttributesModTime = box_hton64(mAttributesModTime); hdr.mOptionsPresent = htonl(options); - + // Write header rStream.Write(&hdr, sizeof(hdr)); - + // Write the attributes? if(StreamAttributes) { @@ -268,7 +268,7 @@ void BackupStoreDirectory::WriteToStream(IOStream &rStream, int16_t FlagsMustBeS { pen->WriteToStream(rStream); } - + // Write dependency info? if(dependencyInfoRequired) { @@ -277,7 +277,7 @@ void BackupStoreDirectory::WriteToStream(IOStream &rStream, int16_t FlagsMustBeS while((pen = i.Next(FlagsMustBeSet, FlagsNotToBeSet)) != 0) { pen->WriteToStreamDependencyInfo(rStream); - } + } } } @@ -301,7 +301,7 @@ BackupStoreDirectory::Entry *BackupStoreDirectory::AddEntry(const Entry &rEntryT delete pnew; throw; } - + return pnew; } @@ -329,7 +329,7 @@ BackupStoreDirectory::AddEntry(const BackupStoreFilename &rName, delete pnew; throw; } - + return pnew; } @@ -356,9 +356,11 @@ void BackupStoreDirectory::DeleteEntry(int64_t ObjectID) return; } } - + // Not found - THROW_EXCEPTION(BackupStoreException, CouldNotFindEntryInDirectory) + THROW_EXCEPTION_MESSAGE(BackupStoreException, CouldNotFindEntryInDirectory, + "Failed to find entry " << BOX_FORMAT_OBJECTID(ObjectID) << + " in directory " << BOX_FORMAT_OBJECTID(mObjectID)); } @@ -396,15 +398,16 @@ BackupStoreDirectory::Entry *BackupStoreDirectory::FindEntryByID(int64_t ObjectI // // -------------------------------------------------------------------------- BackupStoreDirectory::Entry::Entry() - : mModificationTime(0), - mObjectID(0), - mSizeInBlocks(0), - mFlags(0), - mAttributesHash(0), - mMinMarkNumber(0), - mMarkNumber(0), - mDependsNewer(0), - mDependsOlder(0) +: + mModificationTime(0), + mObjectID(0), + mSizeInBlocks(0), + mFlags(0), + mAttributesHash(0), + mMinMarkNumber(0), + mMarkNumber(0), + mDependsNewer(0), + mDependsOlder(0) { } @@ -429,17 +432,18 @@ BackupStoreDirectory::Entry::~Entry() // // -------------------------------------------------------------------------- BackupStoreDirectory::Entry::Entry(const Entry &rToCopy) - : mName(rToCopy.mName), - mModificationTime(rToCopy.mModificationTime), - mObjectID(rToCopy.mObjectID), - mSizeInBlocks(rToCopy.mSizeInBlocks), - mFlags(rToCopy.mFlags), - mAttributesHash(rToCopy.mAttributesHash), - mAttributes(rToCopy.mAttributes), - mMinMarkNumber(rToCopy.mMinMarkNumber), - mMarkNumber(rToCopy.mMarkNumber), - mDependsNewer(rToCopy.mDependsNewer), - mDependsOlder(rToCopy.mDependsOlder) +: + mName(rToCopy.mName), + mModificationTime(rToCopy.mModificationTime), + mObjectID(rToCopy.mObjectID), + mSizeInBlocks(rToCopy.mSizeInBlocks), + mFlags(rToCopy.mFlags), + mAttributesHash(rToCopy.mAttributesHash), + mAttributes(rToCopy.mAttributes), + mMinMarkNumber(rToCopy.mMinMarkNumber), + mMarkNumber(rToCopy.mMarkNumber), + mDependsNewer(rToCopy.mDependsNewer), + mDependsOlder(rToCopy.mDependsOlder) { } @@ -453,16 +457,17 @@ BackupStoreDirectory::Entry::Entry(const Entry &rToCopy) // // -------------------------------------------------------------------------- BackupStoreDirectory::Entry::Entry(const BackupStoreFilename &rName, box_time_t ModificationTime, int64_t ObjectID, int64_t SizeInBlocks, int16_t Flags, uint64_t AttributesHash) - : mName(rName), - mModificationTime(ModificationTime), - mObjectID(ObjectID), - mSizeInBlocks(SizeInBlocks), - mFlags(Flags), - mAttributesHash(AttributesHash), - mMinMarkNumber(0), - mMarkNumber(0), - mDependsNewer(0), - mDependsOlder(0) +: + mName(rName), + mModificationTime(ModificationTime), + mObjectID(ObjectID), + mSizeInBlocks(SizeInBlocks), + mFlags(Flags), + mAttributesHash(AttributesHash), + mMinMarkNumber(0), + mMarkNumber(0), + mDependsNewer(0), + mDependsOlder(0) { } @@ -487,11 +492,11 @@ void BackupStoreDirectory::Entry::ReadFromStream(IOStream &rStream, int Timeout) } // Do reading first before modifying the variables, to be more exception safe - + // Get the filename BackupStoreFilename name; name.ReadFromStream(rStream, Timeout); - + // Get the attributes mAttributes.ReadFromStream(rStream, Timeout); @@ -522,13 +527,13 @@ void BackupStoreDirectory::Entry::WriteToStream(IOStream &rStream) const entry.mSizeInBlocks = box_hton64(mSizeInBlocks); entry.mAttributesHash = box_hton64(mAttributesHash); entry.mFlags = htons(mFlags); - + // Write it rStream.Write(&entry, sizeof(entry)); - + // Write the filename mName.WriteToStream(rStream); - + // Write any attributes mAttributes.WriteToStream(rStream); } @@ -568,12 +573,9 @@ void BackupStoreDirectory::Entry::ReadFromStreamDependencyInfo(IOStream &rStream void BackupStoreDirectory::Entry::WriteToStreamDependencyInfo(IOStream &rStream) const { // Build structure - en_StreamFormatDepends depends; + en_StreamFormatDepends depends; depends.mDependsNewer = box_hton64(mDependsNewer); depends.mDependsOlder = box_hton64(mDependsOlder); // Write rStream.Write(&depends, sizeof(depends)); } - - - |