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>
26 #include <glibmm/fileutils.h>
27 #include <glibmm/miscutils.h>
29 #include <pbd/filesystem.h>
30 #include <pbd/error.h>
37 path::operator/=(const path& rhs)
39 m_path = Glib::build_filename(m_path, rhs.m_path);
44 path::operator/=(const string& rhs)
46 m_path = Glib::build_filename(m_path, rhs);
51 path::operator/=(const char* rhs)
53 m_path = Glib::build_filename(m_path, rhs);
58 exists (const path & p)
60 return Glib::file_test (p.to_string(), Glib::FILE_TEST_EXISTS);
64 is_directory (const path & p)
66 return Glib::file_test (p.to_string(), Glib::FILE_TEST_IS_DIR);
70 create_directory(const path & p)
72 if(is_directory(p)) return false;
74 int error = g_mkdir (p.to_string().c_str(), S_IRWXU|S_IRWXG|S_IRWXO);
78 throw filesystem_error(g_strerror(errno), errno);
84 create_directories(const path & p)
86 if(is_directory(p)) return false;
88 int error = g_mkdir_with_parents (p.to_string().c_str(), S_IRWXU|S_IRWXG|S_IRWXO);
92 throw filesystem_error(g_strerror(errno), errno);
98 basename (const path & p)
100 // I'm not sure if this works quite the same as boost::filesystem::basename
101 return Glib::path_get_basename (p.to_string ());