Logo Search packages:      
Sourcecode: kdar version File versions  Download package

QString KDarConfig::buildDarCommandLine ( KDar::libdarCommand  command  ) 

Returns this KDarConfig's equivalent dar command line

Definition at line 2323 of file kdarConfig.cpp.

References allowOverwrite(), archiveName(), archiveStorageDirectory(), cleanPath(), compressionAlgorithm(), compressionLevel(), compressionMaskList(), compressionMaskType(), diffArchiveDirectory(), differentialBackup(), differentialBackupArchiveName(), directoryMaskList(), directoryMaskTypes(), directoryToBackup(), dryRun(), executeCommand(), extractArchiveDirectory(), fileMaskList(), fileMaskType(), flatRestore(), hourShiftInt(), ignoreDump(), ignoreID(), isolationArchiveName(), keepPruned(), libdarFirstSliceSize(), libdarSliceSize(), minimumCompressionSizeInt(), newArchiveName(), noDelete(), archiveHandle::parseStringSubstitutions(), passwordString(), pauseBetweenSlices(), restoreRecent(), systemEA(), userEA(), verbose(), and warnOnOverwrite().

Referenced by createArchiveThread::run(), kdarView::slotExportDarCreateCommand(), and kdarView::slotExportDarRestoreCommand().

{
    QString darCommand( "dar" );
    QString newName = archiveHandle::parseStringSubstitutions( newArchiveName(), this );
    if ( newName[0] != '/' )
    {
        newName = cleanPath( archiveStorageDirectory() + "/" + newName );
    }
    QString archive = archiveName();
    if ( archive[0] != '/' )
    {
        archive = cleanPath( archiveStorageDirectory() + "/" + archive );
    }
    QString isolationName = isolationArchiveName();
    if ( isolationName[0] != '/' )
    {
        isolationName = cleanPath( archiveStorageDirectory() + "/" + isolationName );
    }
    QString refArchiveName = differentialBackupArchiveName();
    if ( refArchiveName[0] != '/' )
    {
        refArchiveName = cleanPath( archiveStorageDirectory() + "/" + refArchiveName );
    }

    //Other options...
    if ( dryRun() ) darCommand += " -e";
    if ( verbose() ) darCommand += " -v";

    //Compression masks
    QString compressionInclude( " -Y " );
    QString compressionExclude( " -Z " );
    QString compressionString( "" );
    QStringList compressionList( compressionMaskList() );
    for ( QStringList::Iterator it = compressionList.begin(); it != compressionList.end(); ++it )
    {
        if ( compressionMaskType() == KDar::INCLUDE )
        {
            compressionString += compressionInclude + "\"" + *it + "\"";
        }
        else
        {
            compressionString += compressionExclude + "\"" + *it + "\"";
        }
    }

    //File masks
    QString fileInclude( " -I " );
    QString fileExclude( " -X " );
    QString fileString( "" );
    QStringList fileList( fileMaskList() );
    for ( QStringList::Iterator it = fileList.begin(); it != fileList.end(); ++it )
    {
        if ( fileMaskType() == KDar::INCLUDE )
        {
            fileString += fileInclude + "\"" + *it + "\"";
        }
        else
        {
            fileString += fileExclude + "\"" + *it + "\"";
        }
    }

    //Directory filters
    QString directoryInclude( " " );
    QString directoryExclude( " -P " );
    QString directoryIncludeString( "" );
    QString directoryExcludeString( "" );
    QStringList directoryList( directoryMaskList() );
    QStringList maskTypes( directoryMaskTypes() );

    //Make sure the root directory has a trailing slash
    QString root( directoryToBackup() );
    if ( !root.endsWith( "/" ) ) root += "/";

    if ( maskTypes.count() == directoryList.count() )
    {
        QStringList::Iterator typeIterator = maskTypes.begin();
        for( QStringList::Iterator directoryIterator = directoryList.begin(); directoryIterator != directoryList.end(); ++directoryIterator )
        {
            QString filter( *directoryIterator );
            if ( filter.find( root ) == 0 )
            {
                filter.remove( 0, root.length() );
            }
            if ( *typeIterator == i18n( "filter type for inclusion", "Include" ) )
            {
                directoryIncludeString += directoryInclude + "\"" + filter + "\"";
            }
            else //exclude "Exclude" and "Auto" masks
            {
                directoryExcludeString += directoryExclude + "\"" + filter + "\"";
            }
            ++typeIterator;
        }
    }

    switch ( command )
    {
        case KDar::LIBDAR_CREATE:
            darCommand += " -c \"" + newName + "\"";
            darCommand += " -R \"" + root + "\"";
            if ( differentialBackup() ) darCommand += " -A \"" + refArchiveName + "\"";
            if ( !allowOverwrite() ) darCommand += " -n";
            if ( !warnOnOverwrite() ) darCommand += " -w";
            if ( libdarSliceSize() != 0 )
            {
                darCommand += " -s " + QString( libdar::deci( libdarSliceSize() ).human().c_str() );
                if ( libdarFirstSliceSize() != libdarSliceSize() && libdarFirstSliceSize() > 0 )
                {
                    darCommand += " -S " + QString( libdar::deci( libdarFirstSliceSize() ).human().c_str() );
                }
                if ( pauseBetweenSlices() ) darCommand += " -p";
            }
            if ( keepPruned() ) darCommand += " -D";
            if ( compressionAlgorithm() != libdar::none )
            {
                if ( compressionAlgorithm() == libdar::gzip ) darCommand += " -z" + QString::number( compressionLevel() );
                if ( compressionAlgorithm() == libdar::bzip2 ) darCommand += " -y";
                darCommand += " -m " + QString::number( minimumCompressionSizeInt() );
                //Add compression filters here.
                darCommand += compressionString;
            }
            if ( !userEA() ) darCommand += " -u";
            if ( !systemEA() ) darCommand += " -U";
            if ( !executeCommand().isEmpty() ) darCommand += " -E \"" + executeCommand() + "\"";
            if ( !passwordString().isEmpty() ) darCommand += " -K \"" + passwordString() + "\"";
            if ( ignoreDump() ) darCommand += " --nodump";
            if ( ignoreID() ) darCommand += " -O";
            if ( hourShiftInt() != 0 ) darCommand += " -H" + QString::number( hourShiftInt() );
            //File inclusion/exclusion filters:
            darCommand += fileString;
            //Directory filters
            darCommand += directoryExcludeString;
            darCommand += directoryIncludeString;
            break;
        case KDar::LIBDAR_DIFF:
            darCommand += " -d \"" + archive + "\"";
            darCommand += " -R \"" + diffArchiveDirectory() + "\"";
            if ( !userEA() ) darCommand += " -u";
            if ( !systemEA() ) darCommand += " -U";
            if ( ignoreID() ) darCommand += " -O";
            //File inclusion/exclusion filters:
            darCommand += fileString;
            //Directory filters
            darCommand += directoryExcludeString;
            darCommand += directoryIncludeString;
            break;
        case KDar::LIBDAR_ISOLATE:
            darCommand += " -C \"" + isolationName + "\"";
            darCommand += " -A \"" + archive + "\"";
            if ( !allowOverwrite() ) darCommand += " -n";
            if ( !warnOnOverwrite() ) darCommand += " -w";
            if ( libdarSliceSize() != 0 )
            {
                darCommand += " -s " + QString( libdar::deci( libdarSliceSize() ).human().c_str() );
                if ( libdarFirstSliceSize() != libdarSliceSize() && libdarFirstSliceSize() > 0 )
                {
                    darCommand += " -S " + QString( libdar::deci( libdarFirstSliceSize() ).human().c_str() );
                }
                if ( pauseBetweenSlices() ) darCommand += " -p";
            }
            if ( compressionAlgorithm() != libdar::none )
            {
                if ( compressionAlgorithm() == libdar::gzip ) darCommand += " -z" + QString::number( compressionLevel() );
                if ( compressionAlgorithm() == libdar::bzip2 ) darCommand += " -y";
                darCommand += " -m " + QString::number( minimumCompressionSizeInt() );
            }
            if ( !executeCommand().isEmpty() ) darCommand += " -E \"" + executeCommand() + "\"";
            if ( !passwordString().isEmpty() ) darCommand += " -K \"" + passwordString() + "\"";
            break;
        case KDar::LIBDAR_RESTORE:
            darCommand += " -x \"" + archive + "\"";
            darCommand += " -R \"" + extractArchiveDirectory()+ "\"";
            if ( !allowOverwrite() ) darCommand += " -n";
            if ( !warnOnOverwrite() ) darCommand += " -w";
            if ( noDelete() ) darCommand += " -k";
            if ( restoreRecent() ) darCommand += " -r";
            if ( flatRestore() ) darCommand += " -f";
            if ( hourShiftInt() != 0 ) darCommand += " -H" + QString::number( hourShiftInt() );
            if ( !userEA() ) darCommand += " -u";
            if ( !systemEA() ) darCommand += " -U";
            if ( ignoreID() ) darCommand += " -O";
             //File filters:
            darCommand += fileString;
            //directory filters
            darCommand += directoryExcludeString;
            darCommand += directoryIncludeString;
           break;
        case KDar::LIBDAR_TEST:
            darCommand += " -t \"" + archive + "\"";
            //File filters:
            darCommand += fileString;
            //directory filters
            break;
        default:
            ;
    }

    darCommand += "\n";
    return darCommand;
}


Generated by  Doxygen 1.6.0   Back to index