return -1;
}
- _writable = sys::exists_and_writable (_path);
+ _writable = exists_and_writable (_path);
if (!session_template.empty()) {
std::string in_path = session_template_dir_to_file (session_template);
set_dirty();
- _writable = sys::exists_and_writable (xmlpath.to_string());
+ _writable = exists_and_writable (xmlpath.to_string());
if (!state_tree->read (xmlpath.to_string())) {
error << string_compose(_("Could not understand ardour file %1"), xmlpath.to_string()) << endmsg;
return false;
}
+bool
+exists_and_writable (const std::string & p)
+{
+ /* writable() really reflects the whole folder, but if for any
+ reason the session state file can't be written to, still
+ make us unwritable.
+ */
+
+ struct stat statbuf;
+
+ if (g_stat (p.c_str(), &statbuf) != 0) {
+ /* doesn't exist - not writable */
+ return false;
+ } else {
+ if (!(statbuf.st_mode & S_IWUSR)) {
+ /* exists and is not writable */
+ return false;
+ }
+ /* filesystem may be mounted read-only, so even though file
+ * permissions permit access, the mount status does not.
+ * access(2) seems like the best test for this.
+ */
+ if (g_access (p.c_str(), W_OK) != 0) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
} // namespace PBD
return Glib::file_test (p.to_string(), Glib::FILE_TEST_EXISTS);
}
-bool
-exists_and_writable (const std::string & p)
-{
- /* writable() really reflects the whole folder, but if for any
- reason the session state file can't be written to, still
- make us unwritable.
- */
-
- struct stat statbuf;
-
- if (g_stat (p.c_str(), &statbuf) != 0) {
- /* doesn't exist - not writable */
- return false;
- } else {
- if (!(statbuf.st_mode & S_IWUSR)) {
- /* exists and is not writable */
- return false;
- }
- /* filesystem may be mounted read-only, so even though file
- * permissions permit access, the mount status does not.
- * access(2) seems like the best test for this.
- */
- if (g_access (p.to_string().c_str(), W_OK) != 0) {
- return false;
- }
- }
-
- return true;
-}
-
-
bool
is_directory (const path & p)
{
*/
bool equivalent_paths (const std::string &p1, const std::string &p2);
+/// @return true if path at p exists and is writable, false otherwise
+bool exists_and_writable(const std::string & p);
+
} // namespace PBD
#endif
/// @return true if path at p exists
bool exists(const path & p);
-
-/// @return true if path at p exists and is writable, false otherwise
-bool exists_and_writable(const std::string & p);
-
/// @return true if path at p is a directory.
bool is_directory(const path & p);