diff --git a/core/database.c b/core/database.c index 0fdb383b..0d089be4 100644 --- a/core/database.c +++ b/core/database.c @@ -125,7 +125,7 @@ void db_load(struct database *db) __dbe_setup(db, i); } - save = data_file_version(&db->db_file) != OCARINA_MINOR_VERSION; + save = file_version(&db->db_file) != OCARINA_MINOR_VERSION; file_close(&db->db_file); if (save) diff --git a/core/file.c b/core/file.c index 6d67d2a8..82e9007b 100644 --- a/core/file.c +++ b/core/file.c @@ -104,11 +104,11 @@ gchar *file_write_path(struct file *file) return res; } -const unsigned int data_file_version(struct file *data) +const unsigned int file_version(struct file *file) { - if (data->f_file && (data->f_mode == OPEN_READ)) - return data->f_prev; - return data->f_version; + if (file->f_file && (file->f_mode == OPEN_READ)) + return file->f_prev; + return file->f_version; } bool file_exists(struct file *file) diff --git a/core/tags/album.c b/core/tags/album.c index 2c8ce518..e9dda5ff 100644 --- a/core/tags/album.c +++ b/core/tags/album.c @@ -259,7 +259,7 @@ static struct db_entry *album_read(struct file *file, unsigned int index) gchar *line, *name; line = data_file_readl(file); - if (data_file_version(file) == 0) { + if (file_version(file) == 0) { album = __album_parse_v0(line); album_db_upgraded = true; goto out; diff --git a/core/tags/library.c b/core/tags/library.c index 8645aa64..0dcab7d5 100644 --- a/core/tags/library.c +++ b/core/tags/library.c @@ -38,7 +38,7 @@ static struct db_entry *library_read(struct file *file, unsigned int index) int enabled; gchar *path; - if (data_file_version(file) == 0) + if (file_version(file) == 0) data_file_readf(file, "%d", &enabled); data_file_readf(file, " %m[^\n]", &path); diff --git a/core/tags/track.c b/core/tags/track.c index 868afe47..537a25bd 100644 --- a/core/tags/track.c +++ b/core/tags/track.c @@ -155,7 +155,7 @@ static struct db_entry *track_read(struct file *file, unsigned int index) data_file_readf(file, "%u", &library_id); track->tr_library = library_get(library_id); - if (data_file_version(file) == 0) + if (file_version(file) == 0) track_read_v0(file, track); else { data_file_readf(file, "%u %hu", &album_id, &track->tr_track); diff --git a/include/core/file.h b/include/core/file.h index 84b01983..295c57c9 100644 --- a/include/core/file.h +++ b/include/core/file.h @@ -79,7 +79,7 @@ gchar *file_path(struct file *); gchar *file_write_path(struct file *); /* Returns the version number of the file. */ -const unsigned int data_file_version(struct file *); +const unsigned int file_version(struct file *); /* Returns true if the file exists on disk and false otherwise. */ bool file_exists(struct file *); diff --git a/tests/core/file.c b/tests/core/file.c index 85a379bd..6dd7faa7 100644 --- a/tests/core/file.c +++ b/tests/core/file.c @@ -10,7 +10,7 @@ static void test_verify_constructor(struct file *file, gchar *fpath, gchar *ftmp) { g_assert_null(file->f_file); - g_assert_cmpuint(data_file_version(file), ==, OCARINA_MINOR_VERSION); + g_assert_cmpuint(file_version(file), ==, OCARINA_MINOR_VERSION); g_assert_cmpuint(file->f_mode, ==, CLOSED); g_assert_cmpstr_free(file_path(file), ==, fpath); g_assert_cmpstr_free(file_write_path(file), ==, ftmp); @@ -108,7 +108,7 @@ static void test_io() g_assert_true(file_exists(&fout)); g_assert_true(file_open(&fin, OPEN_READ)); - g_assert_cmpuint(data_file_version(&fin), ==, 1); + g_assert_cmpuint(file_version(&fin), ==, 1); g_assert_cmpuint(data_file_readf(&fin, "%u %ms\n", &i, &res), ==, 2); g_assert_cmpuint(i, ==, 1); @@ -128,7 +128,7 @@ static void test_io() g_assert_cmpstr_free(res, ==, "5 PQRST"); file_close(&fin); - g_assert_cmpuint(data_file_version(&fin), ==, OCARINA_MINOR_VERSION); + g_assert_cmpuint(file_version(&fin), ==, OCARINA_MINOR_VERSION); } static void __test_versioning_subprocess(unsigned int out, unsigned int in)