libsaria: Fill out a struct PathInfo

This struct is used by the gui to show how large a library path is
and eventually to remove it from the library.
This commit is contained in:
Bryan Schumaker 2011-10-20 10:23:35 -04:00
parent e8341288b3
commit 2a6d05ebee
3 changed files with 23 additions and 0 deletions

View File

@ -11,6 +11,11 @@ namespace libsaria
{
namespace library
{
struct PathInfo {
string path;
unsigned int size;
};
void load();
void save();
void refresh();
@ -18,6 +23,7 @@ namespace libsaria
void add_path(string);
void play_id(ino_t);
void for_each(void (*)(Track &));
void for_each_path(void (*)(struct PathInfo &));
unsigned int size();
}

View File

@ -34,6 +34,14 @@ void LibraryPath::for_each(void (*ins_func)(Track &))
}
}
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);
}
bool LibraryPath::play_id(ino_t id)
{
map<ino_t, TrackTag>::iterator it;
@ -54,6 +62,13 @@ namespace libsaria
it->second.for_each(ins_func);
}
void library::for_each_path(void (*info_func)(struct library::PathInfo &))
{
map<string, LibraryPath>::iterator it;
for (it = path_map.begin(); it != path_map.end(); it++)
it->second.get_info(info_func);
}
void library::play_id(ino_t id)
{
map<string, LibraryPath>::iterator it;

View File

@ -5,6 +5,7 @@
#include <string>
using namespace std;
#include <libsaria/library.h>
#include <libsaria/path.h>
class LibraryPath
@ -19,6 +20,7 @@ class LibraryPath
~LibraryPath();
void for_each(void (*)(Track &));
void get_info(void (*)(struct libsaria::library::PathInfo &));
void insert_track(ino_t, TrackTag &);
bool play_id(ino_t);
void save(OutFile &);