1/*
2 This file is part of the KDE libraries
3
4 SPDX-FileCopyrightText: 1999 Waldo Bastian <bastian@kde.org>
5 SPDX-FileCopyrightText: 2006 Jaison Lee <lee.jaison@gmail.com>
6 SPDX-FileCopyrightText: 2011 Romain Perier <bambi@ubuntu.com>
7
8 SPDX-License-Identifier: LGPL-2.0-only
9*/
10
11#ifndef KBACKUP_H
12#define KBACKUP_H
13
14#include <QString>
15#include <kcoreaddons_export.h>
16
17/**
18 * @namespace KBackup
19 * Provides utility functions for backup of files.
20 */
21namespace KBackup
22{
23/**
24 * @brief Function to create a backup file for a given filename.
25 *
26 * This function creates a backup file from the given filename.
27 * You can use this method even if you don't use KSaveFile.
28 * @param filename the file to backup
29 * @param backupDir optional directory where to save the backup file in.
30 * If empty (the default), the backup will be in the same directory as @p filename.
31 * @param backupExtension the extension to append to @p filename, "~" by default.
32 * @return true if successful, or false if an error has occurred.
33 */
34KCOREADDONS_EXPORT bool simpleBackupFile(const QString &filename, const QString &backupDir = QString(), const QString &backupExtension = QStringLiteral("~"));
35
36/**
37 * @brief Function to create a backup file for a given filename.
38 *
39 * This function creates a series of numbered backup files from the
40 * given filename.
41 *
42 * The backup file names will be of the form:
43 * \<name\>.\<number\>\<extension\>
44 * for instance
45 * \verbatim chat.3.log \endverbatim
46 *
47 * The new backup file will be have the backup number 1.
48 * Each existing backup file will have its number incremented by 1.
49 * Any backup files with numbers greater than the maximum number
50 * permitted (@p maxBackups) will be removed.
51 * You can use this method even if you don't use KSaveFile.
52 *
53 * @param filename the file to backup
54 * @param backupDir optional directory where to save the backup file in.
55 * If empty (the default), the backup will be in the same directory as
56 * @p filename.
57 * @param backupExtension the extension to append to @p filename,
58 * which is "~" by default. Do not use an extension containing digits.
59 * @param maxBackups the maximum number of backup files permitted.
60 * For best performance a small number (10) is recommended.
61 * @return true if successful, or false if an error has occurred.
62 */
63KCOREADDONS_EXPORT bool numberedBackupFile(const QString &filename,
64 const QString &backupDir = QString(),
65 const QString &backupExtension = QStringLiteral("~"),
66 const uint maxBackups = 10);
67}
68
69#endif
70

source code of kcoreaddons/src/lib/io/kbackup.h