core/tags/library: Convert file to C
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
62fd782710
commit
1b4eb470a7
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Copyright 2014 (c) Anna Schumaker.
|
||||
*/
|
||||
#include <core/tags/library.h>
|
||||
|
@ -8,7 +8,7 @@ static struct database library_db;
|
|||
|
||||
static struct library *__library_alloc(gchar *path, bool enabled)
|
||||
{
|
||||
struct library *library = new struct library;
|
||||
struct library *library = g_malloc(sizeof(struct library));
|
||||
|
||||
dbe_init(&library->li_dbe, library);
|
||||
library->li_size = 0;
|
||||
|
@ -25,7 +25,7 @@ static struct db_entry *library_alloc(const gchar *path)
|
|||
|
||||
static void library_free(struct db_entry *dbe)
|
||||
{
|
||||
delete LIBRARY(dbe);
|
||||
g_free(LIBRARY(dbe));
|
||||
}
|
||||
|
||||
static gchar *library_key(struct db_entry *dbe)
|
|
@ -5,8 +5,8 @@ extern "C" {
|
|||
#include <core/tags/album.h>
|
||||
#include <core/tags/artist.h>
|
||||
#include <core/tags/genre.h>
|
||||
}
|
||||
#include <core/tags/library.h>
|
||||
}
|
||||
#include <core/tags/tags.h>
|
||||
#include <core/tags/track.h>
|
||||
|
||||
|
|
|
@ -1,25 +1,20 @@
|
|||
/**
|
||||
/*
|
||||
* Copyright 2014 (c) Anna Schumaker.
|
||||
*
|
||||
* The Library tag is used to store a single directory added
|
||||
* to Ocarina by the user.
|
||||
*
|
||||
* When writing a Library tag to disk, write out the library_enabled
|
||||
* and library_path fields for each tag.
|
||||
*
|
||||
* ... true /home/Zelda/Music
|
||||
* ... false /home/Link/Music
|
||||
*/
|
||||
#ifndef OCARINA_CORE_TAGS_LIBRARY_H
|
||||
#define OCARINA_CORE_TAGS_LIBRARY_H
|
||||
|
||||
extern "C" {
|
||||
#include <core/database.h>
|
||||
}
|
||||
#include <string>
|
||||
|
||||
/**
|
||||
* The Library tag is used to store a single directory added
|
||||
* to Ocarina by the user.
|
||||
*
|
||||
* When writing a Library tag to disk, write out the _enabled
|
||||
* and _path fields for each tag.
|
||||
*
|
||||
* ... << enabled1 << path1
|
||||
* ... << enabled2 << path2
|
||||
* ... << enabled3 << path3
|
||||
*/
|
||||
struct library {
|
||||
unsigned int li_size; /* This library's track count. */
|
||||
bool li_enabled;/* True if this library is enabled. */
|
||||
|
|
|
@ -10,8 +10,10 @@ extern "C" {
|
|||
#include <core/tags/album.h>
|
||||
#include <core/tags/artist.h>
|
||||
#include <core/tags/genre.h>
|
||||
}
|
||||
#include <core/tags/library.h>
|
||||
}
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,7 +14,7 @@ def TagTest(name, source):
|
|||
res = [ TagTest("album", "album.c") ]
|
||||
res += [ TagTest("artist", "artist.c") ]
|
||||
res += [ TagTest("genre", "genre.c") ]
|
||||
res += [ TagTest("library", "library.cpp") ]
|
||||
res += [ TagTest("library", "library.c") ]
|
||||
|
||||
env.UsePackage("taglib_c")
|
||||
core_objs += [ env.Object("../../../core/tags/tags.cpp") ]
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
/**
|
||||
/*
|
||||
* Copyright 2014 (c) Anna Schumaker.
|
||||
*/
|
||||
#include <core/tags/library.h>
|
||||
#include "../test.h"
|
||||
#include <tests/test.h>
|
||||
|
||||
static void test_verify_zelda(struct library *library)
|
||||
{
|
||||
const struct db_ops *library_ops = test_library_ops();
|
||||
test_equal(library->li_enabled, true);
|
||||
test_equal(library->li_enabled, (bool)true);
|
||||
test_equal(library->li_size, 0);
|
||||
test_equal(library_ops->dbe_key(&library->li_dbe), "/home/Zelda/Music");
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ static void test_verify_zelda(struct library *library)
|
|||
static void test_verify_link(struct library *library)
|
||||
{
|
||||
const struct db_ops *library_ops = test_library_ops();
|
||||
test_equal(library->li_enabled, false);
|
||||
test_equal(library->li_enabled, (bool)false);
|
||||
test_equal(library->li_size, 0);
|
||||
test_equal(library_ops->dbe_key(&library->li_dbe), "/home/Link/Music");
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ static void test_library()
|
|||
{
|
||||
const struct db_ops *library_ops = test_library_ops();
|
||||
struct library *link, *zelda, *library;
|
||||
file f;
|
||||
struct file f;
|
||||
|
||||
link = LIBRARY(library_ops->dbe_alloc("/home/Link/Music"));
|
||||
zelda = LIBRARY(library_ops->dbe_alloc("/home/Zelda/Music"));
|
||||
|
@ -71,7 +71,7 @@ static void test_library_db()
|
|||
struct library *library, *library2;
|
||||
struct database library_db;
|
||||
|
||||
test_not_equal(library_db_get(), NULL);
|
||||
test_not_equal((void *)library_db_get(), NULL);
|
||||
test_equal(library_db_get()->db_size, 0);
|
||||
|
||||
library_db_init();
|
||||
|
@ -79,9 +79,9 @@ static void test_library_db()
|
|||
test_verify_zelda(library);
|
||||
|
||||
test_equal(library_db_get()->db_size, 1);
|
||||
test_equal(library_find("/home/Zelda/Music"), library);
|
||||
test_equal(library_get(0), library);
|
||||
test_equal(library_get(1), (struct library *)NULL);
|
||||
test_equal((void *)library_find("/home/Zelda/Music"), (void *)library);
|
||||
test_equal((void *)library_get(0), (void *)library);
|
||||
test_equal((void *)library_get(1), NULL);
|
||||
|
||||
db_init(&library_db, "library.db", false, library_ops);
|
||||
db_load(&library_db);
|
||||
|
@ -89,11 +89,11 @@ static void test_library_db()
|
|||
test_equal(db_actual_size(&library_db), 1);
|
||||
|
||||
library2 = LIBRARY(db_at(&library_db, 0));
|
||||
test_not_equal(library2, NULL);
|
||||
test_not_equal((void *)library2, NULL);
|
||||
test_verify_zelda(library2);
|
||||
|
||||
library_remove(library);
|
||||
test_equal(library_get(0), (struct library *)NULL);
|
||||
test_equal((void *)library_get(0), (void *)NULL);
|
||||
test_equal(library_db_get()->db_size, 0);
|
||||
|
||||
library_db_deinit();
|
Loading…
Reference in New Issue