#include <inttypes.h>
#include <cstdio>
#include <errno.h>
+
+#include <glibmm/miscutils.h>
+
#include "pbd/error.h"
#include "pbd/enumwriter.h"
{
string fullpath;
- if (path[0] == '/') { // legacy
+ if (Glib::path_is_absolute (path)) { // legacy
fullpath = path;
} else {
fullpath = _a_session.automation_dir();
isnew = false;
- if (pathstr[0] != '/') {
+ if (!Glib::path_is_absolute (pathstr)) {
/* non-absolute pathname: find pathstr in search path */
cnt = 0;
for (vector<ustring>::iterator i = dirs.begin(); i != dirs.end(); ++i) {
- fullpath = *i;
- if (fullpath[fullpath.length()-1] != '/') {
- fullpath += '/';
- }
-
- fullpath += pathstr;
+
+ fullpath = Glib::build_filename (*i, pathstr);
/* i (paul) made a nasty design error by using ':' as a special character in
Ardour 0.99 .. this hack tries to make things sort of work.
*/
ustring shorter = pathstr.substr (0, pos);
- fullpath = *i;
-
- if (fullpath[fullpath.length()-1] != '/') {
- fullpath += '/';
- }
-
- fullpath += shorter;
+ fullpath = Glib::build_filename (*i, shorter);
if (Glib::file_test (pathstr, Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_REGULAR)) {
chan = atoi (pathstr.substr (pos+1));
#include <climits>
#include <cerrno>
+#include <glibmm/miscutils.h>
+
#include "pbd/compose.h"
#include "pbd/error.h"
if (S_ISDIR (statbuf.st_mode)) {
- string::size_type slash = str.find_last_of ('/');
+ string::size_type slash = str.find_last_of (G_DIR_SEPARATOR);
if (slash == string::npos) {
/* a subdirectory of cwd, so statefile should be ... */
- string tmp;
- tmp = str;
- tmp += '/';
- tmp += str;
- tmp += statefile_suffix;
+ string tmp = Glib::build_filename (str, str+statefile_suffix);
/* is it there ? */
} else if (S_ISREG (statbuf.st_mode)) {
- string::size_type slash = str.find_last_of ('/');
+ string::size_type slash = str.find_last_of (G_DIR_SEPARATOR);
string::size_type suffix;
/* remove the suffix */
as "dirname" does.
*/
- string::size_type slash = str.find_last_of ('/');
+ string::size_type slash = str.find_last_of (G_DIR_SEPARATOR);
if (slash == string::npos) {
std::string filepath = (type == DataType::MIDI)
? sdir.midi_path().to_string() : sdir.sound_path().to_string();
- filepath += '/';
- filepath += get_non_existent_filename (hf, type, allow_replacing, filepath, basename, n, channels);
+ filepath = Glib::build_filename (filepath,
+ get_non_existent_filename (hf, type, allow_replacing, filepath, basename, n, channels));
new_paths.push_back (filepath);
}
adjust_capture_position = 0;
- if (nominally_recording || (_session.get_record_enabled() && _session.config.get_punch_in())) {
+ if (nominally_recording || (re && was_recording && _session.get_record_enabled() && _session.config.get_punch_in())) {
OverlapType ot = coverage (first_recordable_frame, last_recordable_frame, transport_frame, transport_frame + nframes);
calculate_record_range(ot, transport_frame, nframes, rec_nframes, rec_offset);
case ':' :
case '\0':
continue;
- case '/' :
+ case G_DIR_SEPARATOR :
if (ladspa_path[found + strlen(standard_paths[i]) + 1] == ':' ||
ladspa_path[found + strlen(standard_paths[i]) + 1] == '\0') {
continue;
_path = string(buf);
if (_path[_path.length()-1] != '/') {
- _path += '/';
+ _path += G_DIR_SEPARATOR;
}
if (Glib::file_test (_path, Glib::FILE_TEST_EXISTS) && ::access (_path.c_str(), W_OK)) {
string statename(*state);
string::size_type start,end;
- if ((start = statename.find_last_of ('/')) != string::npos) {
+ if ((start = statename.find_last_of (G_DIR_SEPARATOR)) != string::npos) {
statename = statename.substr (start+1);
}
continue;
}
- if (prop->value()[0] == '/') {
+ if (Glib::path_is_absolute (prop->value())) {
/* external file, ignore */
continue;
}
ripped = _path;
- if (ripped[ripped.length()-1] == '/') {
+ if (ripped[ripped.length()-1] == G_DIR_SEPARATOR) {
ripped = ripped.substr (0, ripped.length() - 1);
}
newpath = Glib::path_get_dirname (newpath); // "session-dir"
}
- newpath += '/';
- newpath += dead_sound_dir_name;
+ newpath = Glib::build_filename (newpath, dead_sound_dir_name);
if (g_mkdir_with_parents (newpath.c_str(), 0755) < 0) {
error << string_compose(_("Session: cannot create session peakfile folder \"%1\" (%2)"), newpath, strerror (errno)) << endmsg;
return -1;
}
- newpath += '/';
- newpath += Glib::path_get_basename ((*x));
-
- if (access (newpath.c_str(), F_OK) == 0) {
+ newpath = Glib::build_filename (newpath, Glib::path_get_basename ((*x)));
+
+ if (Glib::file_test (newpath, Glib::FILE_TEST_EXISTS)) {
/* the new path already exists, try versioning */
/* remove any leading path */
- if ((pos = path.find_last_of ('/')) != string::npos) {
+ if ((pos = path.find_last_of (G_DIR_SEPARATOR)) != string::npos) {
path = path.substr(pos+1);
}