X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Faudio_library.cc;h=2f09a37633062d55fc13f0be90c864c08a3be54c;hb=cf52d6e4b40111eb04b244ec054055a4ec15dbe0;hp=b64a9ee08dc10ecdf6076151e69cedb3eeed7be9;hpb=e0aaed6d65f160c328cb8b56d7c6552ee15d65e2;p=ardour.git diff --git a/libs/ardour/audio_library.cc b/libs/ardour/audio_library.cc index b64a9ee08d..2f09a37633 100644 --- a/libs/ardour/audio_library.cc +++ b/libs/ardour/audio_library.cc @@ -17,24 +17,33 @@ */ +#ifdef WAF_BUILD +#include "libardour-config.h" +#endif + #include #include +#ifdef HAVE_LRDF #include +#endif + #include #include #include "pbd/compose.h" +#include "pbd/error.h" +#include "pbd/file_utils.h" #include "ardour/audio_library.h" -#include "ardour/utils.h" #include "ardour/filesystem_paths.h" -#include "i18n.h" +#include "pbd/i18n.h" using namespace std; +using namespace PBD; using namespace ARDOUR; namespace { @@ -45,18 +54,20 @@ static const char* TAG = "http://ardour.org/ontology/Tag"; AudioLibrary::AudioLibrary () { - sys::path sfdb_file_path(user_config_directory ()); + std::string sfdb_file_path(user_config_directory ()); + + sfdb_file_path = Glib::build_filename (sfdb_file_path, sfdb_file_name); - sfdb_file_path /= sfdb_file_name; + src = Glib::filename_to_uri (sfdb_file_path); - src = Glib::filename_to_uri (sfdb_file_path.to_string ()); - // workaround for possible bug in raptor that crashes when saving to a // non-existant file. - touch_file(sfdb_file_path.to_string()); + touch_file(sfdb_file_path); +#ifdef HAVE_LRDF lrdf_read_file(src.c_str()); +#endif } AudioLibrary::~AudioLibrary () @@ -66,57 +77,64 @@ AudioLibrary::~AudioLibrary () void AudioLibrary::save_changes () { +#ifdef HAVE_LRDF if (lrdf_export_by_source(src.c_str(), src.substr(5).c_str())) { PBD::warning << string_compose(_("Could not open %1. Audio Library not saved"), src) << endmsg; } +#endif } void AudioLibrary::set_tags (string member, vector tags) { +#ifdef HAVE_LRDF sort (tags.begin(), tags.end()); tags.erase (unique(tags.begin(), tags.end()), tags.end()); - + const string file_uri(Glib::filename_to_uri (member)); - + lrdf_remove_uri_matches (file_uri.c_str()); - + for (vector::iterator i = tags.begin(); i != tags.end(); ++i) { lrdf_add_triple (src.c_str(), file_uri.c_str(), TAG, (*i).c_str(), lrdf_literal); } +#endif } vector AudioLibrary::get_tags (string member) { vector tags; - +#ifdef HAVE_LRDF + char * uri = strdup(Glib::filename_to_uri(member).c_str()); + lrdf_statement pattern; - pattern.subject = strdup(Glib::filename_to_uri(member).c_str()); - pattern.predicate = (char*)TAG; + pattern.subject = uri; + pattern.predicate = const_cast(TAG); pattern.object = 0; pattern.object_type = lrdf_literal; - + lrdf_statement* matches = lrdf_matches (&pattern); - free (pattern.subject); - + lrdf_statement* current = matches; while (current != 0) { tags.push_back (current->object); - + current = current->next; } - + lrdf_free_statements (matches); - + sort (tags.begin(), tags.end()); - + free (uri); +#endif return tags; } void -AudioLibrary::search_members_and (vector& members, const vector tags) +AudioLibrary::search_members_and (vector& members, const vector& tags) { +#ifdef HAVE_LRDF lrdf_statement **head; lrdf_statement* pattern = 0; lrdf_statement* old = 0; @@ -125,8 +143,8 @@ AudioLibrary::search_members_and (vector& members, const vector vector::const_iterator i; for (i = tags.begin(); i != tags.end(); ++i){ pattern = new lrdf_statement; - pattern->subject = (char*)"?"; - pattern->predicate = (char*)TAG; + pattern->subject = const_cast("?"); + pattern->predicate = const_cast(TAG); pattern->object = strdup((*i).c_str()); pattern->next = old; @@ -152,4 +170,5 @@ AudioLibrary::search_members_and (vector& members, const vector pattern = pattern->next; delete old; } +#endif }