3e35c42de25ffe5fe9fe35e0b25db661c2663d74
[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
25 #include "pbd/filesystem.h"
26
27 namespace ARDOUR {
28
29 using std::string;
30 using std::vector;
31 using PBD::sys::path;
32
33 class SessionDirectory
34 {
35 public:
36
37         /**
38          * @param session_path An absolute path to a session directory.
39          */
40         SessionDirectory (const path& session_path);
41
42         /**
43          * @return the absolute path to the root directory of the session
44          */
45         const path root_path() const { return m_root_path; }
46
47         /**
48          * @return the absolute path to the directory in which 
49          * the session stores audio files.
50          *
51          * If the session is an older session with an existing
52          * "sounds" directory then it will return a path to that
53          * directory otherwise it will return the new location
54          * of root_path()/interchange/session_name/audiofiles
55          */
56         const path sound_path () const;
57         
58         /**
59          * @return the absolute path to the directory in which 
60          * the session stores MIDI files, ie
61          * root_path()/interchange/session_name/midifiles
62          */
63         const path midi_path () const;
64         
65         /**
66          * @return the absolute path to the directory in which 
67          * the session stores MIDNAM patch files, ie
68          * root_path()/interchange/session_name/patchfiles
69          */
70         const path midi_patch_path () const;
71
72         /**
73          * @return The absolute path to the directory in which all
74          * peak files are stored for a session.
75          */
76         const path peak_path () const;
77
78         /**
79          * @return The absolute path to the directory that audio
80          * files are moved to when they are no longer part of the
81          * session.
82          */
83         const path dead_sound_path () const;
84         
85         /**
86          * @return The absolute path to the directory that midi
87          * files are moved to when they are no longer part of the
88          * session.
89          */
90         const path dead_midi_path () const;
91
92         /**
93          * @return The absolute path to the directory that audio
94          * files are created in by default when exporting.
95          */
96         const path export_path () const;
97
98         /**
99          * @return true if session directory and all the required 
100          * subdirectories exist.
101          */
102         bool is_valid () const;
103
104         /**
105          * Create the session directory and all the subdirectories.
106          *
107          * @throw PBD::sys::filesystem_error if the directories were
108          * not able to be created.
109          *
110          * @return true If a new session directory was created, otherwise
111          * (if it already existed) false.
112          *
113          * @post is_valid ()
114          */
115         bool create ();
116
117 protected:
118
119         /**
120          * @return The path to the old style sound directory.
121          * It isn't created by create().
122          */
123         const path old_sound_path () const;
124
125         /**
126          * @return The path to the directory under which source directories
127          * are created for different source types.
128          * i.e root_path()/interchange/session_name
129          */
130         const path sources_root() const;
131
132         /**
133          * @return a vector containing the fullpath of all subdirectories.
134          */
135         const vector<PBD::sys::path> sub_directories () const;
136
137         /// The path to the root of the session directory.
138         const path m_root_path;
139 };
140
141 } // namespace ARDOUR
142
143 #endif