libsaria: Move LibraryPath functions to path.cpp
This is really what path.cpp is all about.
This commit is contained in:
parent
d23c1c72f0
commit
b5c8efc6d5
|
@ -3,7 +3,6 @@
|
|||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
#include <libsaria/audio.h>
|
||||
#include <libsaria/model.h>
|
||||
#include <libsaria/callback.h>
|
||||
#include <libsaria/library.h>
|
||||
|
@ -11,61 +10,6 @@ using namespace std;
|
|||
|
||||
static list<LibraryPath> path_list;
|
||||
|
||||
void LibraryPath::for_each(libsaria::SourceModel *model)
|
||||
{
|
||||
list<TrackTag>::iterator it;
|
||||
|
||||
for (it = file_list.begin(); it != file_list.end(); it++) {
|
||||
Track track = Track(&(*it));
|
||||
model->insert(track);
|
||||
}
|
||||
}
|
||||
|
||||
string LibraryPath::get_path()
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
void LibraryPath::get_info(void (*info_func)(struct libsaria::library::PathInfo &))
|
||||
{
|
||||
struct libsaria::library::PathInfo info;
|
||||
info.path = path;
|
||||
info.size = size();
|
||||
info_func(info);
|
||||
}
|
||||
|
||||
list<TrackTag>::iterator LibraryPath::find_id(ino_t &id)
|
||||
{
|
||||
list<TrackTag>::iterator it;
|
||||
for (it = file_list.begin(); it != file_list.end(); it++) {
|
||||
if (it->get_inode() == id)
|
||||
break;
|
||||
}
|
||||
return it;
|
||||
}
|
||||
|
||||
bool LibraryPath::get_info_id(ino_t &id, void (*func)(Track &))
|
||||
{
|
||||
list<TrackTag>::iterator it;
|
||||
it = find_id(id);
|
||||
if (it != file_list.end()) {
|
||||
Track track = Track(&(*it));
|
||||
func(track);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool LibraryPath::play_id(ino_t &id)
|
||||
{
|
||||
list<TrackTag>::iterator it;
|
||||
it = find_id(id);
|
||||
if (it == file_list.end())
|
||||
return false;
|
||||
libsaria::audio::load(it->get_filepath());
|
||||
return true;
|
||||
}
|
||||
|
||||
namespace libsaria
|
||||
{
|
||||
list<LibraryPath> *library::get_path_list()
|
||||
|
|
|
@ -2,12 +2,65 @@
|
|||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
#include <libsaria/audio.h>
|
||||
#include <libsaria/library.h>
|
||||
#include "library.h"
|
||||
|
||||
/*
|
||||
* Definitions for the LibraryPath class
|
||||
*/
|
||||
void LibraryPath::for_each(libsaria::SourceModel *model)
|
||||
{
|
||||
list<TrackTag>::iterator it;
|
||||
|
||||
for (it = file_list.begin(); it != file_list.end(); it++) {
|
||||
Track track = Track(&(*it));
|
||||
model->insert(track);
|
||||
}
|
||||
}
|
||||
|
||||
string LibraryPath::get_path()
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
void LibraryPath::get_info(void (*info_func)(struct libsaria::library::PathInfo &))
|
||||
{
|
||||
struct libsaria::library::PathInfo info;
|
||||
info.path = path;
|
||||
info.size = size();
|
||||
info_func(info);
|
||||
}
|
||||
|
||||
list<TrackTag>::iterator LibraryPath::find_id(ino_t &id)
|
||||
{
|
||||
list<TrackTag>::iterator it;
|
||||
for (it = file_list.begin(); it != file_list.end(); it++) {
|
||||
if (it->get_inode() == id)
|
||||
break;
|
||||
}
|
||||
return it;
|
||||
}
|
||||
|
||||
bool LibraryPath::get_info_id(ino_t &id, void (*func)(Track &))
|
||||
{
|
||||
list<TrackTag>::iterator it;
|
||||
it = find_id(id);
|
||||
if (it != file_list.end()) {
|
||||
Track track = Track(&(*it));
|
||||
func(track);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool LibraryPath::play_id(ino_t &id)
|
||||
{
|
||||
list<TrackTag>::iterator it;
|
||||
it = find_id(id);
|
||||
if (it == file_list.end())
|
||||
return false;
|
||||
libsaria::audio::load(it->get_filepath());
|
||||
return true;
|
||||
}
|
||||
|
||||
LibraryPath::LibraryPath(string dir)
|
||||
{
|
||||
path = dir;
|
||||
|
|
Loading…
Reference in New Issue