diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-02-07 15:30:30 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-02-07 15:30:30 +0000 |
| commit | f5c77f7acdcdd1cc178f172dd49b48c9648b8c8b (patch) | |
| tree | 020b4a98743551b453e123714ce96532c9b2b184 /src/lib | |
| parent | 9298f5a03786be14cfe3c37871e76f749617e6ca (diff) | |
Create parent directories on file() as well as dir().
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/film.cc | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/lib/film.cc b/src/lib/film.cc index 34289e65f..e759b761c 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -449,7 +449,7 @@ Film::read_metadata () ifstream f (file ("metadata").c_str()); if (!f.good()) { - throw OpenFileError (file("metadata")); + throw OpenFileError (file ("metadata")); } multimap<string, string> kv = read_key_value (f); @@ -601,23 +601,31 @@ string Film::dir (string d) const { boost::mutex::scoped_lock lm (_directory_mutex); + boost::filesystem::path p; p /= _directory; p /= d; + boost::filesystem::create_directories (p); + return p.string (); } /** Given a file or directory name, return its full path within the Film's directory. * _directory_mutex must not be locked on entry. + * Any required parent directories will be created. */ string Film::file (string f) const { boost::mutex::scoped_lock lm (_directory_mutex); + boost::filesystem::path p; p /= _directory; p /= f; + + boost::filesystem::create_directories (p.parent_path ()); + return p.string (); } |
