Source Code (Use browser search to find items of interest.)
Class Index
kdat'BackupProfile (./kdeadmin/kdat/BackupProfile.h:27)
class BackupProfile {
QString _name;
QString _lastSavedName;
QString _archiveName;
QString _workingDirectory;
QStrList _relativeFiles;
QStrList _absoluteFiles;
bool _oneFilesystem;
bool _incremental;
QString _snapshotFile;
bool _removeSnapshot;
void calcRelativeFiles();
public:
/**
* Create a new backup profile.
*/
BackupProfile();
/**
* Load the named backup profile from disk.
*
* @param name The name of the backup profile.
*/
BackupProfile( const char* name );
/**
* Destroy the backup profile.
*/
~BackupProfile();
/**
* Load the backup profile from disk.
*/
void load();
/**
* Save the backup profile to disk. If the backup profile was renamed,
* the old backup profile will be removed.
*/
void save();
/**
* Query the name of this backup profile.
*
* @return The name of this profile.
*/
const char* getName();
/**
* Query the name of the archive.
*
* @return The name of the new archive.
*/
const char* getArchiveName();
/**
* Query the working directory for the tar command.
*
* @return The working directory.
*/
const char* getWorkingDirectory();
/**
* Query the list of files to backup, relative to the working directory.
*
* @return The file list.
*/
const QStrList& getRelativeFiles();
/**
* Query the list of files to backup, with their full paths.
*
* @return The file list.
*/
const QStrList& getAbsoluteFiles();
/**
* Query whether or not to cross filesystem boundaries when performing the
* backup.
*
* @return TRUE if the backup is restricted to a single filesystem, FALSE
* if the backup can cross filesystem boundaries.
*/
bool isOneFilesystem();
/**
* Query whether this is to be a GNU incremental backup.
*
* @return TRUE if incremental, otherwise FALSE.
*/
bool isIncremental();
/**
* Query the name of the snapshot file to use for an incremental backup.
*
* @return The name of the snapshot file.
*/
const char* getSnapshotFile();
/**
* Query whether to remove the snapshot file before beginning an
* incremental backup. This has the effect of performing a full backup.
*
* @return TRUE if the snapshot file should be removed, otherwise FALSE.
*/
bool getRemoveSnapshot();
/**
* Set the name of this backup profile.
*
* @param name The name of this profile.
*/
void setName( const char* name );
/**
* Set the name of the archive.
*
* @param archiveName The name of the new archive.
*/
void setArchiveName( const char* archiveName );
/**
* Set the working directory for the tar command.
*
* @param workingDirectory The working directory.
*/
void setWorkingDirectory( const char* workingDirectory );
/**
* Set the list of files to backup, with their full paths.
*
* @param files The file list.
*/
void setAbsoluteFiles( const QStrList& files );
/**
* Set whether or not to cross filesystem boundaries when performing the
* backup.
*
* @param oneFilesystem TRUE if the backup is restricted to a single
* filesystem, FALSE if the backup can cross
* filesystem boundaries.
*/
void setOneFilesystem( bool oneFilesystem );
/**
* Set whether this is to be a GNU incremental backup.
*
* @param incremental TRUE if incremental, otherwise FALSE.
*/
void setIncremental( bool incremental );
/**
* Set the name of the snapshot file to use for an incremental backup.
*
* @param snapshotFile The name of the snapshot file.
*/
void setSnapshotFile( const char* snapshotFile );
/**
* Set whether to remove the snapshot file before beginning an
* incremental backup. This has the effect of performing a full backup.
*
* @param removeSnapshot TRUE if the snapshot file should be removed,
* otherwise FALSE.
*/
void setRemoveSnapshot( bool removeSnapshot );
};
kdat'BackupProfile::BackupProfile() (./kdeadmin/kdat/BackupProfile.cpp:30)
BackupProfile::BackupProfile()
{
}
kdat'BackupProfile::BackupProfile() (./kdeadmin/kdat/BackupProfile.cpp:34)
BackupProfile::BackupProfile( const char* name )
: _name( name ),
_lastSavedName( name )
{
load();
}
kdat'BackupProfile::~BackupProfile() (./kdeadmin/kdat/BackupProfile.cpp:41)
BackupProfile::~BackupProfile()
{
}
kdat'BackupProfile::load() (./kdeadmin/kdat/BackupProfile.cpp:45)
void BackupProfile::load()
{
QString filename = locateLocal( "appdata", _lastSavedName + ".bp");
FILE* fptr = fopen( QFile::encodeName(filename), "r" );
if ( !fptr ) {
return;
}
char buf[4096];
fgets( buf, 4096, fptr );
int version = 0;
sscanf( buf, "%d", &version );
fgets( buf, 4096, fptr );
_name = buf;
_name.truncate( _name.length() - 1 );
fgets( buf, 4096, fptr );
_archiveName = buf;
_archiveName.truncate( _archiveName.length() - 1 );
fgets( buf, 4096, fptr );
_workingDirectory = buf;
_workingDirectory.truncate( _workingDirectory.length() - 1 );
_absoluteFiles.clear();
fgets( buf, 4096, fptr );
int filecount = 0;
sscanf( buf, "%d", &filecount );
for ( int i = 0; i < filecount; i++ ) {
fgets( buf, 4096, fptr );
QString filename = buf;
filename.truncate( filename.length() - 1 );
_absoluteFiles.append( filename );
}
calcRelativeFiles();
fgets( buf, 4096, fptr );
int tmpBool = 0;
sscanf( buf, "%d", &tmpBool );
_oneFilesystem = tmpBool;
fgets( buf, 4096, fptr );
sscanf( buf, "%d", &tmpBool );
_incremental = tmpBool;
fgets( buf, 4096, fptr );
_snapshotFile = buf;
_snapshotFile.truncate( _snapshotFile.length() - 1 );
fgets( buf, 4096, fptr );
sscanf( buf, "%d", &tmpBool );
_removeSnapshot = tmpBool;
fclose( fptr );
}
kdat'BackupProfile::save() (./kdeadmin/kdat/BackupProfile.cpp:105)
void BackupProfile::save()
{
QString filename = locateLocal( "appdata", _lastSavedName + ".bp");
unlink( QFile::encodeName(filename) );
FILE* fptr = fopen( QFile::encodeName(filename), "w" );
if ( !fptr ) {
return;
}
fprintf( fptr, "%d\n", 1 ); // Version
fprintf( fptr, "%s\n", _name.data() );
fprintf( fptr, "%s\n", _archiveName.data() );
fprintf( fptr, "%s\n", _workingDirectory.data() );
fprintf( fptr, "%d\n", _absoluteFiles.count() );
QStrListIterator it( _absoluteFiles );
for ( ; it.current(); ++it ) {
fprintf( fptr, "%s\n", it.current() );
}
fprintf( fptr, "%d\n", _oneFilesystem );
fprintf( fptr, "%d\n", _incremental );
fprintf( fptr, "%s\n", _snapshotFile.data() );
fprintf( fptr, "%d\n", _removeSnapshot );
fclose( fptr );
_lastSavedName = _name.copy();
}
kdat'BackupProfile::getName() (./kdeadmin/kdat/BackupProfile.cpp:135)
const char* BackupProfile::getName()
{
return _name;
}
kdat'BackupProfile::getArchiveName() (./kdeadmin/kdat/BackupProfile.cpp:140)
const char* BackupProfile::getArchiveName()
{
return _archiveName;
}
kdat'BackupProfile::getWorkingDirectory() (./kdeadmin/kdat/BackupProfile.cpp:145)
const char* BackupProfile::getWorkingDirectory()
{
return _workingDirectory;
}
kdat'BackupProfile::getRelativeFiles() (./kdeadmin/kdat/BackupProfile.cpp:150)
const QStrList& BackupProfile::getRelativeFiles()
{
return _relativeFiles;
}
kdat'BackupProfile::getAbsoluteFiles() (./kdeadmin/kdat/BackupProfile.cpp:155)
const QStrList& BackupProfile::getAbsoluteFiles()
{
return _absoluteFiles;
}
kdat'BackupProfile::isOneFilesystem() (./kdeadmin/kdat/BackupProfile.cpp:160)
bool BackupProfile::isOneFilesystem()
{
return _oneFilesystem;
}
kdat'BackupProfile::isIncremental() (./kdeadmin/kdat/BackupProfile.cpp:165)
bool BackupProfile::isIncremental()
{
return _incremental;
}
kdat'BackupProfile::getSnapshotFile() (./kdeadmin/kdat/BackupProfile.cpp:170)
const char* BackupProfile::getSnapshotFile()
{
return _snapshotFile;
}
kdat'BackupProfile::getRemoveSnapshot() (./kdeadmin/kdat/BackupProfile.cpp:175)
bool BackupProfile::getRemoveSnapshot()
{
return _removeSnapshot;
}
kdat'BackupProfile::setName() (./kdeadmin/kdat/BackupProfile.cpp:180)
void BackupProfile::setName( const char* name )
{
_name = name;
BackupProfileManager::instance()->backupProfileModified( this );
}
kdat'BackupProfile::setArchiveName() (./kdeadmin/kdat/BackupProfile.cpp:187)
void BackupProfile::setArchiveName( const char* archiveName )
{
_archiveName = archiveName;
BackupProfileManager::instance()->backupProfileModified( this );
}
kdat'BackupProfile::setWorkingDirectory() (./kdeadmin/kdat/BackupProfile.cpp:194)
void BackupProfile::setWorkingDirectory( const char* workingDirectory )
{
_workingDirectory = workingDirectory;
// Regenerate the list of relative files.
calcRelativeFiles();
BackupProfileManager::instance()->backupProfileModified( this );
}
kdat'BackupProfile::setAbsoluteFiles() (./kdeadmin/kdat/BackupProfile.cpp:204)
void BackupProfile::setAbsoluteFiles( const QStrList& files )
{
_absoluteFiles.clear();
QStrListIterator it( files );
for ( ; it.current(); ++it ) {
_absoluteFiles.append( it.current() );
}
// Make sure working directory is still valid.
for ( it.toFirst(); it.current(); ++it ) {
if ( strncmp( it.current(), _workingDirectory.data(), _workingDirectory.length() ) ) {
// Working directory is not a prefix for this file.
break;
}
}
if ( it.current() ) {
// Pick another working directory.
_workingDirectory = Util::longestCommonPath( _absoluteFiles );
}
// Regenerate the list of relative files.
calcRelativeFiles();
BackupProfileManager::instance()->backupProfileModified( this );
}
kdat'BackupProfile::setOneFilesystem() (./kdeadmin/kdat/BackupProfile.cpp:231)
void BackupProfile::setOneFilesystem( bool oneFilesystem )
{
_oneFilesystem = oneFilesystem;
BackupProfileManager::instance()->backupProfileModified( this );
}
kdat'BackupProfile::setIncremental() (./kdeadmin/kdat/BackupProfile.cpp:238)
void BackupProfile::setIncremental( bool incremental )
{
_incremental = incremental;
BackupProfileManager::instance()->backupProfileModified( this );
}
kdat'BackupProfile::setSnapshotFile() (./kdeadmin/kdat/BackupProfile.cpp:245)
void BackupProfile::setSnapshotFile( const char* snapshotFile )
{
_snapshotFile = snapshotFile;
BackupProfileManager::instance()->backupProfileModified( this );
}
kdat'BackupProfile::setRemoveSnapshot() (./kdeadmin/kdat/BackupProfile.cpp:252)
void BackupProfile::setRemoveSnapshot( bool removeSnapshot )
{
_removeSnapshot = removeSnapshot;
BackupProfileManager::instance()->backupProfileModified( this );
}
kdat'BackupProfile::calcRelativeFiles() (./kdeadmin/kdat/BackupProfile.cpp:259)
void BackupProfile::calcRelativeFiles()
{
_relativeFiles.clear();
int remove = _workingDirectory.length();
if ( remove > 1 ) {
remove++;
}
QStrListIterator it( _absoluteFiles );
for ( it.toFirst(); it.current(); ++it ) {
QString fn = it.current();
fn.remove( 0, remove );
if ( fn.length() == 0 ) {
fn = ".";
}
_relativeFiles.append( fn );
}
}