2 Copyright (C) 2007 Tim Mayberry
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.
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.
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.
22 #include <glib/gstdio.h>
24 #include <giomm/file.h>
29 #include <glibmm/fileutils.h>
30 #include <glibmm/miscutils.h>
32 #include "pbd/filesystem.h"
33 #include "pbd/error.h"
34 #include "pbd/compose.h"
35 #include "pbd/pathscanner.h"
46 path::operator/=(const path& rhs)
48 m_path = Glib::build_filename(m_path, rhs.m_path);
53 path::operator/=(const string& rhs)
55 m_path = Glib::build_filename(m_path, rhs);
60 path::operator/=(const char* rhs)
62 m_path = Glib::build_filename(m_path, rhs);
67 exists (const path & p)
69 return Glib::file_test (p.to_string(), Glib::FILE_TEST_EXISTS);
73 is_directory (const path & p)
75 return Glib::file_test (p.to_string(), Glib::FILE_TEST_IS_DIR);
79 create_directory(const path & p)
81 if(is_directory(p)) return false;
83 int error = g_mkdir (p.to_string().c_str(), S_IRWXU|S_IRWXG|S_IRWXO);
87 throw filesystem_error(g_strerror(errno), errno);
93 create_directories(const path & p)
95 if(is_directory(p)) return false;
97 int error = g_mkdir_with_parents (p.to_string().c_str(), S_IRWXU|S_IRWXG|S_IRWXO);
101 throw filesystem_error(g_strerror(errno), errno);