tentative fix for a crash that occurs when switching backends.
[ardour.git] / libs / ardour / ardour / session_directory.h
1 /*
2         Copyright (C) 2007 Tim Mayberry
3
4         This program is free software; you can redistribute it and/or modify
5         it under the terms of the GNU General Public License as published by
6         the Free Software Foundation; either version 2 of the License, or
7         (at your option) any later version.
8
9         This program is distributed in the hope that it will be useful,
10         but WITHOUT ANY WARRANTY; without even the implied warranty of
11         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12         GNU General Public License for more details.
13
14         You should have received a copy of the GNU General Public License
15         along with this program; if not, write to the Free Software
16         Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18
19 #ifndef __ardour_session_directory_h__
20 #define __ardour_session_directory_h__
21
22 #include <string>
23 #include <vector>
24 #include <map>
25
26 #include "ardour/libardour_visibility.h"
27
28 namespace ARDOUR {
29
30 class LIBARDOUR_API SessionDirectory
31 {
32 public:
33
34         /**
35          * @param session_path An absolute path to a session directory.
36          */
37         SessionDirectory (const std::string& session_path);
38
39         /**
40          * Change the root path of this SessionDirectory object
41          */
42         SessionDirectory& operator= (const std::string& path);
43
44         /**
45          * @return the absolute path to the root directory of the session
46          */
47         const std::string root_path() const { return m_root_path; }
48
49         /**
50          * @return the absolute path to the directory in which
51          * the session stores audio files.
52          *
53          * If the session is an older session with an existing
54          * "sounds" directory then it will return a path to that
55          * directory otherwise it will return the new location
56          * of root_path()/interchange/session_name/audiofiles
57          */
58         const std::string sound_path () const;
59
60         /**
61          * @return the absolute path to the directory in which
62          * the session stores audio files for Ardour 2.X.
63          *
64          * If the session is an older session with an existing
65          * "sounds" directory then it will return a path to that
66          * directory otherwise it will return the new location
67          * of root_path()/interchange/session_name/audiofiles
68          */
69         const std::string sound_path_2X () const;
70
71         /**
72          * @return the absolute path to the directory in which
73          * the session stores MIDI files, ie
74          * root_path()/interchange/session_name/midifiles
75          */
76         const std::string midi_path () const;
77
78         /**
79          * @return the absolute path to the directory in which
80          * the session stores MIDNAM patch files, ie
81          * root_path()/interchange/session_name/patchfiles
82          */
83         const std::string midi_patch_path () const;
84
85         /**
86          * @return The absolute path to the directory in which all
87          * peak files are stored for a session.
88          */
89         const std::string peak_path () const;
90
91         /**
92          * @return The absolute path to the directory in which all
93          * video files are stored for a session.
94          */
95         const std::string video_path () const;
96
97         /**
98          * @return The absolute path to the directory that source
99          * files are moved to when they are no longer part of the
100          * session.
101          */
102         const std::string dead_path () const;
103
104         /**
105          * @return The absolute path to the directory that audio
106          * files are created in by default when exporting.
107          */
108         const std::string export_path () const;
109
110         /**
111          * @return true if session directory and all the required
112          * subdirectories exist.
113          */
114         bool is_valid () const;
115
116         /**
117          * Create the session directory and all the subdirectories.
118          *
119          * @return true If a new session directory and subdirectories were
120          * created, otherwise false.
121          *
122          * @post is_valid ()
123          */
124         bool create ();
125
126         /**
127          * @return The path to the directory under which source directories
128          * are created for different source types.
129          * i.e root_path()/interchange/session_name
130          */
131         const std::string sources_root() const;
132
133         /**
134          * @return The path to the directory under which source directories
135          * are created for different source types in Ardour 2.X
136          * i.e root_path()/interchange/session_name
137          */
138         const std::string sources_root_2X() const;
139
140 private:
141
142         /**
143          * @return The path to the old style sound directory.
144          * It isn't created by create().
145          */
146         const std::string old_sound_path () const;
147
148         /**
149          * @return a vector containing the fullpath of all subdirectories.
150          */
151         const std::vector<std::string> sub_directories () const;
152
153         /// The path to the root of the session directory.
154         std::string m_root_path;
155
156         static std::map<std::string,std::string> root_cache;
157 };
158
159 } // namespace ARDOUR
160
161 #endif