RecordDirectory.cpp
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7 
8  This program is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 2 of the
11  License, or (at your option) any later version. See the file
12  COPYING included with this distribution for more information.
13 */
14 
15 #include "RecordDirectory.h"
16 #include "TempDirectory.h"
17 
18 #include <QDir>
19 #include <QDateTime>
20 
21 #include "Debug.h"
22 
23 QString
25 {
26  QDir parent(TempDirectory::getInstance()->getContainingPath());
27  QString subdirname("recorded");
28 
29  if (!parent.mkpath(subdirname)) {
30  SVCERR << "ERROR: RecordDirectory::getRecordContainerDirectory: Failed to create recorded dir in \"" << parent.canonicalPath() << "\"" << endl;
31  return "";
32  } else {
33  return parent.filePath(subdirname);
34  }
35 }
36 
37 QString
39 {
40  QDir parent(getRecordContainerDirectory());
41  QDateTime now = QDateTime::currentDateTime();
42  QString subdirname = QString("%1").arg(now.toString("yyyyMMdd"));
43 
44  if (!parent.mkpath(subdirname)) {
45  SVCERR << "ERROR: RecordDirectory::getRecordDirectory: Failed to create recorded dir in \"" << parent.canonicalPath() << "\"" << endl;
46  return "";
47  } else {
48  return parent.filePath(subdirname);
49  }
50 }
51 
52 QString
54 {
55  QDir parent(getRecordContainerDirectory());
56  QDateTime now = QDateTime::currentDateTime();
57  QString subdirname = "converted";
58 
59  if (!parent.mkpath(subdirname)) {
60  SVCERR << "ERROR: RecordDirectory::getConvertedAudioDirectory: Failed to create recorded dir in \"" << parent.canonicalPath() << "\"" << endl;
61  return "";
62  } else {
63  return parent.filePath(subdirname);
64  }
65 }
66 
67 
static QString getRecordDirectory()
Return the directory in which a recorded file should be saved.
static TempDirectory * getInstance()
static QString getRecordContainerDirectory()
Return the root "recorded files" directory.
static QString getConvertedAudioDirectory()
Return the directory in which an audio file converted from a data file should be saved.
#define SVCERR
Definition: Debug.h:109