Library Tag: Make root_path private

And just change the name of the variable to "_path".

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2014-11-12 08:31:09 -05:00
parent f83765d11e
commit 01e514736e
6 changed files with 14 additions and 13 deletions

View File

@ -177,7 +177,7 @@ void library :: update(Library *library)
}; };
if (library) { if (library) {
scan.path = library->root_path; scan.path = library->primary_key();
idle :: schedule(validate_library, library); idle :: schedule(validate_library, library);
idle :: schedule(scan_path, scan); idle :: schedule(scan_path, scan);
} }

View File

@ -29,7 +29,7 @@ Track :: Track() : library(NULL), artist(NULL), album(NULL), genre(NULL){}
Track :: Track(const std::string &f, Library *l) Track :: Track(const std::string &f, Library *l)
: library(l), artist(NULL), album(NULL), genre(NULL), : library(l), artist(NULL), album(NULL), genre(NULL),
play_count(0), last_year(0), last_month(0), last_day(0), 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++; library->count++;
} }
@ -137,7 +137,7 @@ bool Track :: tag()
const std::string Track :: path() const const std::string Track :: path() const
{ {
return library->root_path + "/" + filepath; return library->primary_key() + "/" + filepath;
} }
void Track :: played() void Track :: played()

View File

@ -10,22 +10,22 @@ Library :: Library()
} }
Library :: Library(const std::string &s) 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 const std::string Library :: primary_key() const
{ {
return root_path; return _path;
} }
void Library :: read(File &f) void Library :: read(File &f)
{ {
f >> enabled; f >> enabled;
root_path = f.getline(); _path = f.getline();
} }
void Library :: write(File &f) void Library :: write(File &f)
{ {
f << enabled << " " << root_path; f << enabled << " " << _path;
} }

View File

@ -11,9 +11,10 @@
* Library tag * Library tag
*/ */
class Library : public DatabaseEntry { class Library : public DatabaseEntry {
private:
std::string _path; /**< Path to the root directory of this library. */
public: public:
/** Path to the directory containing this library's audio files */
std::string root_path;
/** Number of tracks in this library */ /** Number of tracks in this library */
unsigned int count; unsigned int count;
/** True if the library is enabled, false otherwise */ /** True if the library is enabled, false otherwise */

View File

@ -46,7 +46,7 @@ static void list_path(Library *lib)
row[c_cols.c_id] = lib->index(); row[c_cols.c_id] = lib->index();
row[c_cols.c_enabled] = lib->enabled; row[c_cols.c_enabled] = lib->enabled;
row[c_cols.c_size] = lib->count; 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() static void remove_banned_tracks()

View File

@ -10,7 +10,7 @@ static void test_library_tag()
Library library("/home/Zelda/Music"); Library library("/home/Zelda/Music");
File f("library_tag", 0); 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.count, (unsigned)0);
test_equal(library.enabled, true); test_equal(library.enabled, true);
@ -21,7 +21,7 @@ static void test_library_tag()
f.close(); f.close();
library = Library(); 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.count, (unsigned)0);
test_equal(library.enabled, false); test_equal(library.enabled, false);
@ -29,7 +29,7 @@ static void test_library_tag()
library.read(f); library.read(f);
f.close(); 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.count, (unsigned)0);
test_equal(library.enabled, true); test_equal(library.enabled, true);
} }