Fixed typo. Was not getting any text after pRecord->GetRecordType() (which was proba...
[vss2svn.git] / ssphys / SSPhys / InfoCommand.cpp
blob2f5a2523091dbd6fcbcfbdd17bb0d608d80126bb
1 // InfoCommand.cpp: implementation of the CInfoCommand class.
2 //
3 //////////////////////////////////////////////////////////////////////
5 #include "StdAfx.h"
6 #include "InfoCommand.h"
7 #include "Formatter.h"
8 #include <SSPhysLib/SSFiles.h>
9 #include <SSPhysLib/SSObject.h>
10 #include <SSPhysLib/SSItemInfoObject.h>
12 //////////////////////////////////////////////////////////////////////
13 // Construction/Destruction
14 //////////////////////////////////////////////////////////////////////
16 CInfoCommand::CInfoCommand()
17 : CMultiArgCommand ("info", "report on all or specific records of a VSS physical file")
21 po::options_description CInfoCommand::GetOptionsDescription () const
23 po::options_description descr (CMultiArgCommand::GetOptionsDescription());
24 descr.add_options ()
25 ("basic,b", "show only basic information about the records")
26 ("offset,o", po::value <int> (), "only display information of the record at a specific offset");
27 return descr;
30 void CInfoCommand::Info (SSRecordPtr pRecord, bool bBasicInfo)
32 if (bBasicInfo)
34 std::auto_ptr<SSObject> pObject (new SSObject(pRecord));
35 GetFormatter()->Format (*pObject);
37 else
39 std::auto_ptr<SSObject> pObject (SSObject::MakeObject(pRecord));
40 GetFormatter()->Format (*pObject);
44 void CInfoCommand::Execute (po::variables_map const& options, std::string const& arg)
46 bool bBasicInfo = false;
47 bool bDisplayAtOffset = false;
48 int offset = 0;
50 if (options.count("basic"))
51 bBasicInfo = true;
52 if (options.count("offset"))
54 bDisplayAtOffset = true;
55 offset = options["offset"].as<int> ();
58 std::auto_ptr <SSRecordFile> pFile (SSRecordFile::MakeFile (arg));
60 if (pFile.get ())
62 GetFormatter()->BeginFile (arg);
63 if (bDisplayAtOffset)
65 SSRecordPtr pRecord = pFile->GetRecord(offset);
66 Info (pRecord, bBasicInfo);
68 else
70 SSRecordPtr pRecord = pFile->GetFirstRecord();
71 while (pRecord)
73 Info (pRecord, bBasicInfo);
74 pRecord = pFile->FindNextRecord(pRecord);
78 GetFormatter()->EndFile ();