Source Code (Use browser search to find items of interest.)
Class Index
kfind'KfArchiver (./kdeutils/kfind/kfarch.h:13)
class KfArchiver
{
public:
/**
*Create a KfArchiver
*/
KfArchiver() {};
/**
* Create a KfArchiver with archiver
*/
KfArchiver(const QString&);
virtual ~KfArchiver() {}
/** Initialize archivers
* Call this function before you call any other function.
* This function initializes global variable
*/
static void init();
/**
* This function scans file ~/.kfindrc for archivers
*/
static void initArchivers();
/**
* Returns archiver name
*/
QString getArName() { return arName; };
/**
* Returns comment for archiver
*/
QString getArComment() { return arComment; };
/**
* Returns command for creating new archive
*/
QString getOnCreate() { return arOnCreate; };
/**
* Returns command for updating archive
*/
QString getOnUpdate() { return arOnUpdate; };
/** Returns valid pattern for archive
* Returns the extensions assoziated with this archiver,
* for example '.tar.gz' or '.zip'.
*/
QStrList& getArPattern() { return arPattern; };
/**
* Sets the comment
*/
void setComment( const QString& _c) { arComment = _c; }
/**
* Sets the command for archive creating
*/
void setOnCreate( const QString& _command) { arOnCreate = _command; }
/**
* Sets the command for archive updating
*/
void setOnUpdate( const QString& _command) { arOnUpdate = _command; }
/**
* Add a pattern which matches this type.
*/
virtual void addPattern( const char *_p )
{ if ( arPattern.find( _p ) == -1 ) arPattern.append( _p ); }
/**
*Find archiver by pattern.
*
* If for the given pattern no KfArchiver has been created, the function
* will retun 0L;
*/
static KfArchiver *findByPattern( const char *_pattern );
protected:
QString arName;
QString arComment;
QString arOnCreate;
QString arOnUpdate;
QStrList arPattern;
};
kfind'KfArchiver::KfArchiver() (./kdeutils/kfind/kfarch.cpp:18)
KfArchiver::KfArchiver(const QString& _archiver)
{
arName = _archiver;
};
/// Initialize archivers global varibles
kfind'KfArchiver::init() (./kdeutils/kfind/kfarch.cpp:24)
void KfArchiver::init()
{
archivers = new QList<KfArchiver>;
// Read the archivers
initArchivers();
};
/// This function scans file ~/.kfindrc for archivers
kfind'KfArchiver::initArchivers() (./kdeutils/kfind/kfarch.cpp:33)
void KfArchiver::initArchivers()
{
QString name;
KConfig *config = KApplication::kApplication()->config();
config->setGroup( "Archiver Types" );
QString arch = config->readEntry( "Archivers" );
//Create Tar Archive Entry when no entry found in rc file
if ( arch.isEmpty() )
{
arch="tar;";
config->setGroup( "Archiver Types" );
config->writeEntry( "Archivers", arch );
config->setGroup( "tar" );
config->writeEntry( "Comment", "Tar" );
config->writeEntry( "ExecOnCreate", "tar cf %a -C %d %n" );
config->writeEntry( "ExecOnUpdate", "tar uf %a -C %d %n" );
config->writeEntry( "Pattern", "*.tar;" );
};
int pos = 0;
int old_pos = 0;
QStrList names; // Temporally stores names of archives
while ( ( pos = arch.find( ";", pos ) ) != - 1 )
{
// Read a archiver names from the list
name = arch.mid( old_pos, pos - old_pos );
if (names.find(name.ascii()) == -1 )
names.append(name.ascii());
pos++;
old_pos = pos;
};
for (name = names.first(); name!=0L; name = names.next())
{
config->setGroup( name );
QString comment = config->readEntry( "Comment" );
QString oncreate = config->readEntry( "ExecOnCreate" );
QString onupdate = config->readEntry( "ExecOnUpdate" );
QString patterns = config->readEntry( "Pattern" );
if ( !( oncreate.isEmpty()
| onupdate.isEmpty() ) )
{
KfArchiver *ar = new KfArchiver( name.ascii() );
ar -> setComment(comment);
ar -> setOnCreate(oncreate);
ar -> setOnUpdate(onupdate);
pos=0;
old_pos=0;
while ( ( pos = patterns.find( ";", pos ) ) != - 1 )
{
// Read a pattern from the list
QString pattern = patterns.mid( old_pos, pos - old_pos );
ar->addPattern( pattern.ascii() );
pos++;
old_pos = pos;
};
archivers->append(ar);
};
};
};
kfind'KfArchiver::findByPattern() (./kdeutils/kfind/kfarch.cpp:103)
KfArchiver* KfArchiver::findByPattern( const char *_pattern )
{
KfArchiver *arch;
for ( arch = archivers->first(); arch != 0L; arch = archivers->next() )
{
QStrList & pattern = arch->getArPattern();
char *s;
for ( s = pattern.first(); s != 0L; s = pattern.next() )
if ( strcmp( s, _pattern ) == 0 )
return arch;
};
return 0L;
};