KBackup

KBackup Namespace Reference

Functions

bool backupFile (const QString &qFilename, const QString &backupDir)
 
 KCOREADDONS_DEPRECATED_VERSION_BELATED (5, 75, 5, 0,"Use simpleBackupFile() or numberedBackupFile() directly") KCOREADDONS_EXPORT bool backupFile(const QString &filename
 
bool numberedBackupFile (const QString &filename, const QString &backupDir=QString(), const QString &backupExtension=QStringLiteral("~"), const uint maxBackups=10)
 
bool rcsBackupFile (const QString &filename, const QString &backupDir=QString(), const QString &backupMessage=QString())
 
bool simpleBackupFile (const QString &filename, const QString &backupDir=QString(), const QString &backupExtension=QStringLiteral("~"))
 

Variables

const QStringbackupDir = QString())
 

Detailed Description

Provides utility functions for backup of files.

Function Documentation

KBackup::KCOREADDONS_DEPRECATED_VERSION_BELATED ( ,
75  ,
,
,
"Use simpleBackupFile() or numberedBackupFile() directly"   
) const

Function to create a backup file before saving.

Warning
This code lost its former functionality during the conversion from KDELibs4 to KDE Framrworks 5. It now only forwards and calls
KBackup::simpleBackupFile(filename, backupDir, QStringLiteral("~")));
To restore the former functionality for your software, which read the backup type (simple or numbered), extension string, and maximum number of backup files from the user's global configuration, you could use code like this:
KConfigGroup configGroup(KSharedConfig::openConfig(), "Backups"); // look in the Backups section
const QString type = configGroup.readEntry("Type", QStringLiteral("simple"));
const QString extension = configGroup.readEntry("Extension", QStringLiteral("~"));
bool success = false;
if (type == QLatin1String("numbered")) {
const int maxNumber = configGroup.readEntry("MaxBackups", 10);
success = numberedBackupFile(filename, backupDir, extension, maxNumber);
} else {
success = simpleBackupFile(filename, backupDir, extension);
}
Parameters
filenamethe file to backup
backupDiroptional directory where to save the backup file in. If empty (the default), the backup will be in the same directory as filename.
Returns
true if successful, or false if an error has occurred.
Deprecated:
Since 5.0, use simpleBackupFile() or numberedBackupFile() directly
KCOREADDONS_EXPORT bool KBackup::numberedBackupFile ( const QString filename,
const QString backupDir = QString(),
const QString backupExtension = QStringLiteral("~"),
const uint  maxBackups = 10 
)

Function to create a backup file for a given filename.

This function creates a series of numbered backup files from the given filename.

The backup file names will be of the form: <name>.<number><extension> for instance

chat.3.log 

The new backup file will be have the backup number 1. Each existing backup file will have its number incremented by 1. Any backup files with numbers greater than the maximum number permitted (maxBackups) will be removed. You can use this method even if you don't use KSaveFile.

Parameters
filenamethe file to backup
backupDiroptional directory where to save the backup file in. If empty (the default), the backup will be in the same directory as filename.
backupExtensionthe extension to append to filename, which is "~" by default. Do not use an extension containing digits.
maxBackupsthe maximum number of backup files permitted. For best performance a small number (10) is recommended.
Returns
true if successful, or false if an error has occurred.

Definition at line 125 of file kbackup.cpp.

KCOREADDONS_EXPORT bool KBackup::rcsBackupFile ( const QString filename,
const QString backupDir = QString(),
const QString backupMessage = QString() 
)

Function to create an rcs backup file for a given filename.

This function creates a rcs-formatted backup file from the given filename.

The backup file names will be of the form: <name>,v for instance

photo.jpg,v 

The new backup file will be in RCS format. Each existing backup file will be committed as a new revision. You can use this method even if you don't use KSaveFile.

Parameters
filenamethe file to backup
backupDiroptional directory where to save the backup file in. If empty (the default), the backup will be in the same directory as filename.
backupMessageis the RCS commit message for this revision.
Returns
true if successful, or false if an error has occurred.
Deprecated:
Since 5.75, no known users

Definition at line 50 of file kbackup.cpp.

KCOREADDONS_EXPORT bool KBackup::simpleBackupFile ( const QString filename,
const QString backupDir = QString(),
const QString backupExtension = QStringLiteral("~") 
)

Function to create a backup file for a given filename.

This function creates a backup file from the given filename. You can use this method even if you don't use KSaveFile.

Parameters
filenamethe file to backup
backupDiroptional directory where to save the backup file in. If empty (the default), the backup will be in the same directory as filename.
backupExtensionthe extension to append to filename, "~" by default.
Returns
true if successful, or false if an error has occurred.

Definition at line 33 of file kbackup.cpp.

This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat Nov 21 2020 23:02:16 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.