libsaria: Library code can access the path_list directly
This makes more sense than using an accessor function. Nothing outside the library can use this variable, so there shouldn't be other problems.
This commit is contained in:
parent
fe8a293377
commit
995a372a6e
|
@ -11,7 +11,6 @@ static void do_load()
|
|||
{
|
||||
unsigned int size;
|
||||
string dir;
|
||||
list<LibraryPath> *path_list = libsaria::library::get_path_list();
|
||||
InFile in("library.lib");
|
||||
|
||||
if (!in.good())
|
||||
|
@ -20,8 +19,8 @@ static void do_load()
|
|||
|
||||
for (unsigned int i = 0; i < size; i++) {
|
||||
in >> dir;
|
||||
path_list->push_back(LibraryPath());
|
||||
path_list->back().load_file(in, dir);
|
||||
path_list.push_back(LibraryPath());
|
||||
path_list.back().load_file(in, dir);
|
||||
}
|
||||
|
||||
libsaria::library::sort_list();
|
||||
|
@ -49,11 +48,10 @@ namespace libsaria
|
|||
void library::save()
|
||||
{
|
||||
OutFile out("library.lib");
|
||||
list<LibraryPath> *path_list = get_path_list();
|
||||
list<LibraryPath>::iterator it;
|
||||
|
||||
out << path_list->size() << "\n";
|
||||
for (it = path_list->begin(); it != path_list->end(); it++)
|
||||
out << path_list.size() << "\n";
|
||||
for (it = path_list.begin(); it != path_list.end(); it++)
|
||||
it->save(out);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,14 +8,10 @@ using namespace std;
|
|||
#include <libsaria/library.h>
|
||||
#include "library.h"
|
||||
|
||||
static list<LibraryPath> path_list;
|
||||
list<LibraryPath> path_list;
|
||||
|
||||
namespace libsaria
|
||||
{
|
||||
list<LibraryPath> *library::get_path_list()
|
||||
{
|
||||
return &path_list;
|
||||
}
|
||||
|
||||
LibraryPath *library::get_path(string dir)
|
||||
{
|
||||
|
|
|
@ -13,6 +13,8 @@ using namespace std;
|
|||
#include "path/path.h"
|
||||
#include "list/list.h"
|
||||
|
||||
extern list<LibraryPath> path_list;
|
||||
|
||||
class ScanTask : public IdleTask
|
||||
{
|
||||
private:
|
||||
|
|
|
@ -56,18 +56,17 @@ namespace libsaria
|
|||
|
||||
void library::add_path(string dir)
|
||||
{
|
||||
get_path_list()->push_back(LibraryPath(dir));
|
||||
path_list.push_back(LibraryPath(dir));
|
||||
update_path(dir);
|
||||
}
|
||||
|
||||
void library::remove_path(string dir)
|
||||
{
|
||||
list<LibraryPath> *path_list = get_path_list();
|
||||
list<LibraryPath>::iterator it;
|
||||
|
||||
for (it = path_list->begin(); it != path_list->end(); it++) {
|
||||
for (it = path_list.begin(); it != path_list.end(); it++) {
|
||||
if (it->get_path() == dir) {
|
||||
path_list->erase(it);
|
||||
path_list.erase(it);
|
||||
save();
|
||||
refresh();
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue