File indexing completed on 2024-05-19 03:56:19
0001 /* 0002 This file is part of the KDE libraries 0003 0004 SPDX-FileCopyrightText: 1999 Waldo Bastian <bastian@kde.org> 0005 SPDX-FileCopyrightText: 2006 Jaison Lee <lee.jaison@gmail.com> 0006 SPDX-FileCopyrightText: 2011 Romain Perier <bambi@ubuntu.com> 0007 0008 SPDX-License-Identifier: LGPL-2.0-only 0009 */ 0010 0011 #ifndef KBACKUP_H 0012 #define KBACKUP_H 0013 0014 #include <QString> 0015 #include <kcoreaddons_export.h> 0016 0017 /** 0018 * @namespace KBackup 0019 * Provides utility functions for backup of files. 0020 */ 0021 namespace KBackup 0022 { 0023 /** 0024 * @brief Function to create a backup file for a given filename. 0025 * 0026 * This function creates a backup file from the given filename. 0027 * You can use this method even if you don't use KSaveFile. 0028 * @param filename the file to backup 0029 * @param backupDir optional directory where to save the backup file in. 0030 * If empty (the default), the backup will be in the same directory as @p filename. 0031 * @param backupExtension the extension to append to @p filename, "~" by default. 0032 * @return true if successful, or false if an error has occurred. 0033 */ 0034 KCOREADDONS_EXPORT bool simpleBackupFile(const QString &filename, const QString &backupDir = QString(), const QString &backupExtension = QStringLiteral("~")); 0035 0036 /** 0037 * @brief Function to create a backup file for a given filename. 0038 * 0039 * This function creates a series of numbered backup files from the 0040 * given filename. 0041 * 0042 * The backup file names will be of the form: 0043 * \<name\>.\<number\>\<extension\> 0044 * for instance 0045 * \verbatim chat.3.log \endverbatim 0046 * 0047 * The new backup file will be have the backup number 1. 0048 * Each existing backup file will have its number incremented by 1. 0049 * Any backup files with numbers greater than the maximum number 0050 * permitted (@p maxBackups) will be removed. 0051 * You can use this method even if you don't use KSaveFile. 0052 * 0053 * @param filename the file to backup 0054 * @param backupDir optional directory where to save the backup file in. 0055 * If empty (the default), the backup will be in the same directory as 0056 * @p filename. 0057 * @param backupExtension the extension to append to @p filename, 0058 * which is "~" by default. Do not use an extension containing digits. 0059 * @param maxBackups the maximum number of backup files permitted. 0060 * For best performance a small number (10) is recommended. 0061 * @return true if successful, or false if an error has occurred. 0062 */ 0063 KCOREADDONS_EXPORT bool numberedBackupFile(const QString &filename, 0064 const QString &backupDir = QString(), 0065 const QString &backupExtension = QStringLiteral("~"), 0066 const uint maxBackups = 10); 0067 } 0068 0069 #endif