#ifndef LIBSARIA_LIBRARY_SOURCE_H
#define LIBSARIA_LIBRARY_SOURCE_H

#include <map>
#include <string>
using namespace std;

#include <libsaria/library.h>
#include <libsaria/model.h>
#include <libsaria/path.h>

class LibraryPath
{
	private:
		string path;
		map <ino_t, TrackTag> file_map;

	public:
		LibraryPath(string);
		LibraryPath(InFile &, string);
		~LibraryPath();

		void for_each(libsaria::SourceModel *);
		void get_info(void (*)(struct libsaria::library::PathInfo &));
		bool get_info_id(ino_t &, void (*)(Track &));
		void insert_track(ino_t &, TrackTag &);
		bool play_id(ino_t &);
		void save(OutFile &);
		void update();
		unsigned int size();
};

class ScanTask : public IdleTask
{
	private:
		LibraryPath *library;
		string dir;
		bool end_dir;
		void tag_file(file);

	public:
		ScanTask(LibraryPath *, string, bool);
		~ScanTask();
		void run_task();
};

map<string, LibraryPath> *get_library_map();
LibraryPath *get_library_path(string);

#endif /* LIBSARIA_LIBRARY_SOURCE_H */
