annotate base/TempWriteFile.h @ 1459:3a128665fa6f horizontal-scale

Fixes to logarithmic scale tick intervals. The approach here is not right, though -- and I've left in a failing test or two to remind me of that
author Chris Cannam
date Wed, 02 May 2018 14:17:10 +0100
parents 1c9bbbb6116a
children
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@1359 15 #ifndef SV_TEMP_WRITE_FILE_H
Chris@1359 16 #define SV_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 class TempWriteFile
Chris@674 27 {
Chris@674 28 public:
Chris@674 29 TempWriteFile(QString targetFileName); // may throw FileOperationFailed
Chris@674 30
Chris@674 31 /**
Chris@674 32 * Destroy the temporary file object. If moveToTarget has not
Chris@674 33 * been called, the associated temporary file will be deleted
Chris@674 34 * without being copied to the target location.
Chris@674 35 */
Chris@674 36 ~TempWriteFile();
Chris@674 37
Chris@674 38 /**
Chris@674 39 * Return the name of the temporary file. Unless the constructor
Chris@674 40 * threw an exception, this file will have been created already
Chris@674 41 * (but it will not be open).
Chris@674 42 *
Chris@674 43 * (If moveToTarget has already been called, return an empty
Chris@674 44 * string.)
Chris@674 45 */
Chris@674 46 QString getTemporaryFilename();
Chris@674 47
Chris@674 48 /**
Chris@674 49 * Rename the temporary file to the target filename.
Chris@674 50 */
Chris@674 51 void moveToTarget();
Chris@674 52
Chris@674 53 protected:
Chris@674 54 QString m_target;
Chris@674 55 QString m_temp;
Chris@674 56 };
Chris@674 57
Chris@674 58
Chris@674 59 #endif