File indexing completed on 2024-05-12 16:20:57
0001 /* 0002 * Copyright (c) 2008 Jeff Mitchell <kde-dev@emailgoeshere.com> 0003 * 0004 * This program is free software; you can redistribute it and/or modify 0005 * it under the terms of the GNU General Public License as published by 0006 * the Free Software Foundation; either version 2 of the License, or 0007 * (at your option) any later version. 0008 * 0009 * This program is distributed in the hope that it will be useful, 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0012 * GNU General Public License for more details. 0013 * 0014 * You should have received a copy of the GNU General Public License 0015 * along with this program; if not, write to the Free Software 0016 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 0017 */ 0018 0019 #ifndef SAFEFILESAVER_H 0020 #define SAFEFILESAVER_H 0021 0022 #include <QString> 0023 #include <QByteArray> 0024 0025 /** 0026 * @class SafeFileSaver 0027 * @author Jeff Mitchell <kde-dev@emailgoeshere.com> 0028 */ 0029 0030 class SafeFileSaver 0031 { 0032 public: 0033 explicit SafeFileSaver( const QString &origPath ); 0034 ~SafeFileSaver(); 0035 0036 QString prepareToSave(); 0037 bool doSave(); 0038 void failRemoveCopy( bool revert ); 0039 bool cleanupSave(); 0040 0041 void setVerbose( bool verbose ) { m_verbose = verbose; } 0042 void setPrefix( const QString &prefix ) { if( !prefix.isEmpty() ) m_prefix = prefix; } 0043 0044 private: 0045 QString m_origPath; 0046 QString m_tempSavePath; 0047 QString m_origRenamedSavePath; 0048 QString m_tempSaveDigest; 0049 bool m_cleanupNeeded; 0050 bool m_verbose; 0051 QString m_prefix; 0052 }; 0053 0054 #endif 0055