1 // InfoCommand.cpp: implementation of the CInfoCommand class.
3 //////////////////////////////////////////////////////////////////////
6 #include "InfoCommand.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());
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");
30 void CInfoCommand::Info (SSRecordPtr pRecord
, bool bBasicInfo
)
34 std::auto_ptr
<SSObject
> pObject (new SSObject(pRecord
));
35 GetFormatter()->Format (*pObject
);
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;
50 if (options
.count("basic"))
52 if (options
.count("offset"))
54 bDisplayAtOffset
= true;
55 offset
= options
["offset"].as
<int> ();
58 std::auto_ptr
<SSRecordFile
> pFile (SSRecordFile::MakeFile (arg
));
62 GetFormatter()->BeginFile (arg
);
65 SSRecordPtr pRecord
= pFile
->GetRecord(offset
);
66 Info (pRecord
, bBasicInfo
);
70 SSRecordPtr pRecord
= pFile
->GetFirstRecord();
73 Info (pRecord
, bBasicInfo
);
74 pRecord
= pFile
->FindNextRecord(pRecord
);
78 GetFormatter()->EndFile ();