annotate base/TempWriteFile.h @ 872:afeb580b1b57 tonioni

Add methods to return new Clipboard points with particular characteristics (this is an immutable object)
author Chris Cannam
date Fri, 10 Jan 2014 15:21:01 +0000
parents 920e3880f7b4
children 1c9bbbb6116a
rev   line source
Chris@674 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@674 2
Chris@674 3 /*
Chris@674 4 Sonic Visualiser
Chris@674 5 An audio file viewer and annotation editor.
Chris@674 6 Centre for Digital Music, Queen Mary, University of London.
Chris@674 7
Chris@674 8 This program is free software; you can redistribute it and/or
Chris@674 9 modify it under the terms of the GNU General Public License as
Chris@674 10 published by the Free Software Foundation; either version 2 of the
Chris@674 11 License, or (at your option) any later version. See the file
Chris@674 12 COPYING included with this distribution for more information.
Chris@674 13 */
Chris@674 14
Chris@674 15 #ifndef _TEMP_WRITE_FILE_H_
Chris@674 16 #define _TEMP_WRITE_FILE_H_
Chris@674 17
Chris@674 18 #include <QTemporaryFile>
Chris@674 19
Chris@674 20 /**
Chris@674 21 * A class that manages the creation of a temporary file with a given
Chris@674 22 * prefix and the renaming of that file to the prefix after use. For
Chris@674 23 * use when saving a file over an existing one, to avoid clobbering
Chris@674 24 * the original before the save is complete.
Chris@674 25 */
Chris@674 26
Chris@674 27 class TempWriteFile
Chris@674 28 {
Chris@674 29 public:
Chris@674 30 TempWriteFile(QString targetFileName); // may throw FileOperationFailed
Chris@674 31
Chris@674 32 /**
Chris@674 33 * Destroy the temporary file object. If moveToTarget has not
Chris@674 34 * been called, the associated temporary file will be deleted
Chris@674 35 * without being copied to the target location.
Chris@674 36 */
Chris@674 37 ~TempWriteFile();
Chris@674 38
Chris@674 39 /**
Chris@674 40 * Return the name of the temporary file. Unless the constructor
Chris@674 41 * threw an exception, this file will have been created already
Chris@674 42 * (but it will not be open).
Chris@674 43 *
Chris@674 44 * (If moveToTarget has already been called, return an empty
Chris@674 45 * string.)
Chris@674 46 */
Chris@674 47 QString getTemporaryFilename();
Chris@674 48
Chris@674 49 /**
Chris@674 50 * Rename the temporary file to the target filename.
Chris@674 51 */
Chris@674 52 void moveToTarget();
Chris@674 53
Chris@674 54 protected:
Chris@674 55 QString m_target;
Chris@674 56 QString m_temp;
Chris@674 57 };
Chris@674 58
Chris@674 59
Chris@674 60 #endif