From 01e514736e1e7d63920dbe409acd62e9c13fe2d5 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Wed, 12 Nov 2014 08:31:09 -0500 Subject: [PATCH] Library Tag: Make root_path private And just change the name of the variable to "_path". Signed-off-by: Anna Schumaker --- core/library.cpp | 2 +- core/tags.cpp | 4 ++-- core/tags/library.cpp | 8 ++++---- include/core/tags/library.h | 5 +++-- lib/colmgr.cpp | 2 +- tests/core/tags/library.cpp | 6 +++--- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/core/library.cpp b/core/library.cpp index 2023b244..6d1f75dc 100644 --- a/core/library.cpp +++ b/core/library.cpp @@ -177,7 +177,7 @@ void library :: update(Library *library) }; if (library) { - scan.path = library->root_path; + scan.path = library->primary_key(); idle :: schedule(validate_library, library); idle :: schedule(scan_path, scan); } diff --git a/core/tags.cpp b/core/tags.cpp index 26d6c85a..82e0386d 100644 --- a/core/tags.cpp +++ b/core/tags.cpp @@ -29,7 +29,7 @@ Track :: Track() : library(NULL), artist(NULL), album(NULL), genre(NULL){} Track :: Track(const std::string &f, Library *l) : library(l), artist(NULL), album(NULL), genre(NULL), play_count(0), last_year(0), last_month(0), last_day(0), - filepath(f.substr(l->root_path.size() + 1)) + filepath(f.substr(l->primary_key().size() + 1)) { library->count++; } @@ -137,7 +137,7 @@ bool Track :: tag() const std::string Track :: path() const { - return library->root_path + "/" + filepath; + return library->primary_key() + "/" + filepath; } void Track :: played() diff --git a/core/tags/library.cpp b/core/tags/library.cpp index 8edef7c1..4b06aaf9 100644 --- a/core/tags/library.cpp +++ b/core/tags/library.cpp @@ -10,22 +10,22 @@ Library :: Library() } Library :: Library(const std::string &s) - : root_path(s), count(0), enabled(true) + : _path(s), count(0), enabled(true) { } const std::string Library :: primary_key() const { - return root_path; + return _path; } void Library :: read(File &f) { f >> enabled; - root_path = f.getline(); + _path = f.getline(); } void Library :: write(File &f) { - f << enabled << " " << root_path; + f << enabled << " " << _path; } diff --git a/include/core/tags/library.h b/include/core/tags/library.h index 8360b147..c8952963 100644 --- a/include/core/tags/library.h +++ b/include/core/tags/library.h @@ -11,9 +11,10 @@ * Library tag */ class Library : public DatabaseEntry { +private: + std::string _path; /**< Path to the root directory of this library. */ + public: - /** Path to the directory containing this library's audio files */ - std::string root_path; /** Number of tracks in this library */ unsigned int count; /** True if the library is enabled, false otherwise */ diff --git a/lib/colmgr.cpp b/lib/colmgr.cpp index fd165547..7c281c2c 100644 --- a/lib/colmgr.cpp +++ b/lib/colmgr.cpp @@ -46,7 +46,7 @@ static void list_path(Library *lib) row[c_cols.c_id] = lib->index(); row[c_cols.c_enabled] = lib->enabled; row[c_cols.c_size] = lib->count; - row[c_cols.c_path] = lib->root_path; + row[c_cols.c_path] = lib->primary_key(); } static void remove_banned_tracks() diff --git a/tests/core/tags/library.cpp b/tests/core/tags/library.cpp index b33c9774..b1cb695f 100644 --- a/tests/core/tags/library.cpp +++ b/tests/core/tags/library.cpp @@ -10,7 +10,7 @@ static void test_library_tag() Library library("/home/Zelda/Music"); File f("library_tag", 0); - test_equal(library.root_path, (std::string)"/home/Zelda/Music"); + test_equal(library.primary_key(), (std::string)"/home/Zelda/Music"); test_equal(library.count, (unsigned)0); test_equal(library.enabled, true); @@ -21,7 +21,7 @@ static void test_library_tag() f.close(); library = Library(); - test_equal(library.root_path, (std::string)""); + test_equal(library.primary_key(), (std::string)""); test_equal(library.count, (unsigned)0); test_equal(library.enabled, false); @@ -29,7 +29,7 @@ static void test_library_tag() library.read(f); f.close(); - test_equal(library.root_path, (std::string)"/home/Zelda/Music"); + test_equal(library.primary_key(), (std::string)"/home/Zelda/Music"); test_equal(library.count, (unsigned)0); test_equal(library.enabled, true); }