core/tags/library: Add library_file() function
To help with finding the full path of files that are located in the library's directory. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
24504c7de8
commit
446f1228cf
|
@ -78,3 +78,8 @@ void library_set_enabled(struct library *library, bool enabled)
|
|||
library->li_enabled = enabled;
|
||||
db_save(&library_db);
|
||||
}
|
||||
|
||||
std::string library_file(struct library *library, const std::string &path)
|
||||
{
|
||||
return library->li_path + "/" + path;
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ const std::string Track :: date() const
|
|||
const std::string Track :: path() const
|
||||
{
|
||||
if (_library)
|
||||
return _library->primary_key() + "/" + _path;
|
||||
return library_file(_library, _path);
|
||||
return "";
|
||||
}
|
||||
|
||||
|
|
|
@ -76,4 +76,7 @@ void library_remove(struct library *);
|
|||
/* Called to configure if the library tag is enabled. */
|
||||
void library_set_enabled(struct library *, bool);
|
||||
|
||||
/* Called to find the full path of files under the library directory. */
|
||||
std::string library_file(struct library *, const std::string &);
|
||||
|
||||
#endif /* OCARINA_CORE_TAGS_LIBRARY_H */
|
||||
|
|
|
@ -50,10 +50,12 @@ static void test_library()
|
|||
file_open(&f, OPEN_READ);
|
||||
library->read(f);
|
||||
test_verify_link(library);
|
||||
test_equal(library_file(library, "navi.mp3"), "/home/Link/Music/navi.mp3");
|
||||
|
||||
library->read(f);
|
||||
file_close(&f);
|
||||
test_verify_zelda(library);
|
||||
test_equal(library_file(library, "impa.ogg"), "/home/Zelda/Music/impa.ogg");
|
||||
|
||||
delete library;
|
||||
delete zelda;
|
||||
|
|
Loading…
Reference in New Issue