home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 13
/
mediashare_13.zip
/
mediashare_13
/
ZIPPED
/
PROGRAM
/
WTJ9403.ZIP
/
WILDASS
/
SOURCE
/
GRPFILE.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-13
|
2KB
|
131 lines
#include <afxwin.h>
#include <afxext.h>
#include <ctl3d.h>
#include "grpfile.h"
ProgramMgrGroup::ProgramMgrGroup( const char * pszSrc )
{
CFile aFile( pszSrc, CFile::modeRead );
// read the header
GROUPHEADER gh;
aFile.Read( &gh, sizeof(GROUPHEADER) );
// read the name
aFile.Seek( gh.pName, CFile::begin );
while ( TRUE )
{
char aChar;
aFile.Read( &aChar, sizeof(char) );
if ( aChar != '\0' )
m_strName += aChar;
else
break;
}
// ok. now lets read the items
// allocate memory to holf the offsetes to the
// itemdata entries
WORD * pOffset = new WORD[gh.cItems];
// read the offsets
aFile.Seek( sizeof(GROUPHEADER), CFile::begin );
aFile.Read( pOffset, gh.cItems*sizeof(WORD) );
// iterate the items.
// take care of invalid items; these don`t hva
// an offset, but instead windows puts an
// 0 in the array of offsets
for( WORD iItems = 0; iItems<gh.cItems; iItems++ )
{
if ( ! pOffset[iItems] )
continue;
else
{
ProgramMgrItem * pItem = new ProgramMgrItem( aFile, pOffset[iItems] );
AddTail( pItem );
}
}
// free the tmp buffer
delete [] pOffset;
}
ProgramMgrGroup::~ProgramMgrGroup()
{
for ( POSITION pos=GetHeadPosition(); pos!=NULL; )
{
delete GetNext( pos );
}
}
const char *
ProgramMgrGroup::Name() const
{
return m_strName;
}
// items
ProgramMgrItem::ProgramMgrItem( CFile& rFile, WORD cbOffset )
{
rFile.Seek( cbOffset, CFile::begin );
ITEMDATA id;
rFile.Read( &id, sizeof(ITEMDATA) );
rFile.Seek( id.pName, CFile::begin );
// read the items name
while ( TRUE )
{
char aChar;
rFile.Read( &aChar, sizeof(char) );
if ( aChar != '\0' )
m_strName += aChar;
else
break;
}
// read the items command
rFile.Seek( id.pCommand, CFile::begin );
while ( TRUE )
{
char aChar;
rFile.Read( &aChar, sizeof(char) );
if ( aChar != '\0' )
m_strPath += aChar;
else
break;
}
}
const char *
ProgramMgrItem::Name() const
{
return m_strName;
}
const char *
ProgramMgrItem::Path() const
{
return m_strPath;
}