core/file: Rename data_file_version() -> file_version()

Now it can be used by cache files, too.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2018-02-20 15:43:56 -05:00
parent 35d53855f5
commit 07f832ad26
7 changed files with 12 additions and 12 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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 *);

View File

@ -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)